Skip to content

Commit

Permalink
Pass --stop-after <phase> through to benchmarking subprocesses
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen committed May 28, 2021
1 parent 1db9512 commit 947b373
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/cli/src/benchmark.rs
Expand Up @@ -300,12 +300,18 @@ impl BenchmarkCommand {
.arg("--measure")
.arg(self.measure.to_string())
.arg("--output-format")
.arg(self.output_format.to_string())
.arg(&wasm);
.arg(self.output_format.to_string());

if self.small_workloads {
command.env("WASM_BENCH_USE_SMALL_WORKLOAD", "1");
}

if let Some(phase) = self.stop_after_phase {
command.arg("--stop-after").arg(phase.to_string());
}

command.arg("--").arg(&wasm);

let output = command
.output()
.context("failed to run benchmark subprocess")?;
Expand Down
38 changes: 38 additions & 0 deletions crates/cli/tests/tests.rs
Expand Up @@ -47,6 +47,44 @@ fn help() {
sightglass_cli().arg("help").assert().success();
}

#[test]
fn benchmark_stop_after_compilation() {
sightglass_cli_benchmark()
.arg("--processes")
.arg("2")
.arg("--iterations-per-process")
.arg("1")
.arg("--stop-after")
.arg("compilation")
.arg(benchmark("noop"))
.assert()
.success()
.stdout(
predicate::str::contains("Compilation")
.and(predicate::str::contains("Instantiation").not())
.and(predicate::str::contains("Execution").not()),
);
}

#[test]
fn benchmark_stop_after_instantiation() {
sightglass_cli_benchmark()
.arg("--processes")
.arg("2")
.arg("--iterations-per-process")
.arg("1")
.arg("--stop-after")
.arg("instantiation")
.arg(benchmark("noop"))
.assert()
.success()
.stdout(
predicate::str::contains("Compilation")
.and(predicate::str::contains("Instantiation"))
.and(predicate::str::contains("Execution").not()),
);
}

#[test]
fn benchmark_json() {
let assert = sightglass_cli_benchmark()
Expand Down

0 comments on commit 947b373

Please sign in to comment.