Skip to content

Commit

Permalink
benches: rustfmt
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaxiao (mossaka) Zhou <[email protected]>
  • Loading branch information
Mossaka committed Dec 6, 2024
1 parent dac7815 commit 8061d57
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
use std::process::Command;
use std::time::{Duration, Instant};

use criterion::{criterion_group, criterion_main, Criterion};

fn run_container(runtime: &str, oci: bool) -> Duration {
let start = Instant::now();

let image_name = if oci {
"ghcr.io/containerd/runwasi/wasi-demo-oci:latest" // OCI artifact
} else {
"ghcr.io/containerd/runwasi/wasi-demo-app:latest"
};

let container_name = "testwasm";
let wasm_file = if oci { "wasi-demo-oci.wasm" } else { "wasi-demo-app.wasm" };

let wasm_file = if oci {
"wasi-demo-oci.wasm"
} else {
"wasi-demo-app.wasm"
};

let output = Command::new("sudo")
.args([
"ctr",
Expand All @@ -24,13 +29,16 @@ fn run_container(runtime: &str, oci: bool) -> Duration {
container_name,
wasm_file,
"echo",
"hello"
"hello",
])
.output()
.expect("Failed to execute command");

if !output.status.success() {
panic!("Container failed to run: {}", String::from_utf8_lossy(&output.stderr));
panic!(
"Container failed to run: {}",
String::from_utf8_lossy(&output.stderr)
);
} else {
let stdout_str = String::from_utf8_lossy(&output.stdout);
assert!(stdout_str.contains("hello"));
Expand All @@ -41,9 +49,9 @@ fn run_container(runtime: &str, oci: bool) -> Duration {

fn benchmark_startup(c: &mut Criterion) {
let mut group = c.benchmark_group("wasi-demo-app");

const RUNTIMES: &[&str] = &["wasmtime", "wasmedge", "wasmer", "wamr"];

for runtime in RUNTIMES {
group.bench_function(runtime, |b| {

Check failure on line 56 in benches/containerd-shim-benchmarks/benches/wasi-demo-app-benchmarks.rs

View workflow job for this annotation

GitHub Actions / benchmark

the trait bound `String: From<&&str>` is not satisfied
b.iter(|| run_container(runtime, false));
Expand All @@ -65,4 +73,4 @@ criterion_group! {
targets = benchmark_startup
}

criterion_main!(benches);
criterion_main!(benches);

0 comments on commit 8061d57

Please sign in to comment.