From 44c0cc231b66e329a62e301d1e6f3c90701c23b9 Mon Sep 17 00:00:00 2001 From: willcl-ark Date: Thu, 13 Mar 2025 08:45:56 +0000 Subject: [PATCH 1/3] expose HYPERFINE_ITERATION to intermediate commands Fixes: #781 Expose the `$HYPERFINE_ITERATION` variable to intermediate commands. This will allow iteration-specific prepare/conclude, such as: ```bash hyperfine --runs 5 --prepare 'echo touch file${HYPERFINE_ITERATION}.dat' \ 'echo testing file${HYPERFINE_ITERATION}.dat' \ --conclude 'echo rm file${HYPERFINE_ITERATION}.dat' --show-output ``` --- src/benchmark/executor.rs | 12 ++-- src/benchmark/mod.rs | 56 +++++++++++------- tests/integration_tests.rs | 116 +++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 26 deletions(-) diff --git a/src/benchmark/executor.rs b/src/benchmark/executor.rs index ac6577b..10dee7d 100644 --- a/src/benchmark/executor.rs +++ b/src/benchmark/executor.rs @@ -36,7 +36,7 @@ pub trait Executor { fn run_command_and_measure( &self, command: &Command<'_>, - iteration: BenchmarkIteration, + iteration: &BenchmarkIteration, command_failure_action: Option, output_policy: &CommandOutputPolicy, ) -> Result; @@ -56,7 +56,7 @@ pub trait Executor { fn run_command_and_measure_common( mut command: std::process::Command, - iteration: BenchmarkIteration, + iteration: &BenchmarkIteration, command_failure_action: CmdFailureAction, command_input_policy: &CommandInputPolicy, command_output_policy: &CommandOutputPolicy, @@ -132,7 +132,7 @@ impl Executor for RawExecutor<'_> { fn run_command_and_measure( &self, command: &Command<'_>, - iteration: BenchmarkIteration, + iteration: &BenchmarkIteration, command_failure_action: Option, output_policy: &CommandOutputPolicy, ) -> Result { @@ -175,7 +175,7 @@ impl Executor for ShellExecutor<'_> { fn run_command_and_measure( &self, command: &Command<'_>, - iteration: BenchmarkIteration, + iteration: &BenchmarkIteration, command_failure_action: Option, output_policy: &CommandOutputPolicy, ) -> Result { @@ -230,7 +230,7 @@ impl Executor for ShellExecutor<'_> { // Just run the shell without any command let res = self.run_command_and_measure( &Command::new(None, ""), - BenchmarkIteration::NonBenchmarkRun, + &BenchmarkIteration::NonBenchmarkRun, None, &CommandOutputPolicy::Null, ); @@ -304,7 +304,7 @@ impl Executor for MockExecutor { fn run_command_and_measure( &self, command: &Command<'_>, - _iteration: BenchmarkIteration, + _iteration: &BenchmarkIteration, _command_failure_action: Option, _output_policy: &CommandOutputPolicy, ) -> Result { diff --git a/src/benchmark/mod.rs b/src/benchmark/mod.rs index a45f9a0..e68323d 100644 --- a/src/benchmark/mod.rs +++ b/src/benchmark/mod.rs @@ -58,11 +58,12 @@ impl<'a> Benchmark<'a> { command: &Command<'_>, error_output: &'static str, output_policy: &CommandOutputPolicy, + iteration: &executor::BenchmarkIteration, ) -> Result { self.executor .run_command_and_measure( command, - executor::BenchmarkIteration::NonBenchmarkRun, + iteration, Some(CmdFailureAction::RaiseError), output_policy, ) @@ -74,6 +75,7 @@ impl<'a> Benchmark<'a> { &self, parameters: impl IntoIterator>, output_policy: &CommandOutputPolicy, + iteration: executor::BenchmarkIteration, ) -> Result { let command = self .options @@ -85,7 +87,7 @@ impl<'a> Benchmark<'a> { Append ' || true' to the command if you are sure that this can be ignored."; Ok(command - .map(|cmd| self.run_intermediate_command(&cmd, error_output, output_policy)) + .map(|cmd| self.run_intermediate_command(&cmd, error_output, output_policy, &iteration)) .transpose()? .unwrap_or_default()) } @@ -95,6 +97,7 @@ impl<'a> Benchmark<'a> { &self, parameters: impl IntoIterator>, output_policy: &CommandOutputPolicy, + iteration: executor::BenchmarkIteration, ) -> Result { let command = self .options @@ -106,7 +109,7 @@ impl<'a> Benchmark<'a> { Append ' || true' to the command if you are sure that this can be ignored."; Ok(command - .map(|cmd| self.run_intermediate_command(&cmd, error_output, output_policy)) + .map(|cmd| self.run_intermediate_command(&cmd, error_output, output_policy, &iteration)) .transpose()? .unwrap_or_default()) } @@ -116,11 +119,12 @@ impl<'a> Benchmark<'a> { &self, command: &Command<'_>, output_policy: &CommandOutputPolicy, + iteration: &executor::BenchmarkIteration, ) -> Result { let error_output = "The preparation command terminated with a non-zero exit code. \ Append ' || true' to the command if you are sure that this can be ignored."; - self.run_intermediate_command(command, error_output, output_policy) + self.run_intermediate_command(command, error_output, output_policy, iteration) } /// Run the command specified by `--conclude`. @@ -128,11 +132,12 @@ impl<'a> Benchmark<'a> { &self, command: &Command<'_>, output_policy: &CommandOutputPolicy, + iteration: executor::BenchmarkIteration, ) -> Result { let error_output = "The conclusion command terminated with a non-zero exit code. \ Append ' || true' to the command if you are sure that this can be ignored."; - self.run_intermediate_command(command, error_output, output_policy) + self.run_intermediate_command(command, error_output, output_policy, &iteration) } /// Run the benchmark for a single command @@ -165,10 +170,10 @@ impl<'a> Benchmark<'a> { ) }); - let run_preparation_command = || { + let run_preparation_command = |iteration: &executor::BenchmarkIteration| { preparation_command .as_ref() - .map(|cmd| self.run_preparation_command(cmd, output_policy)) + .map(|cmd| self.run_preparation_command(cmd, output_policy, iteration)) .transpose() }; @@ -184,14 +189,18 @@ impl<'a> Benchmark<'a> { self.command.get_parameters().iter().cloned(), ) }); - let run_conclusion_command = || { + let run_conclusion_command = |iteration: executor::BenchmarkIteration| { conclusion_command .as_ref() - .map(|cmd| self.run_conclusion_command(cmd, output_policy)) + .map(|cmd| self.run_conclusion_command(cmd, output_policy, iteration)) .transpose() }; - self.run_setup_command(self.command.get_parameters().iter().cloned(), output_policy)?; + self.run_setup_command( + self.command.get_parameters().iter().cloned(), + output_policy, + executor::BenchmarkIteration::NonBenchmarkRun, + )?; // Warmup phase if self.options.warmup_count > 0 { @@ -206,14 +215,15 @@ impl<'a> Benchmark<'a> { }; for i in 0..self.options.warmup_count { - let _ = run_preparation_command()?; + let warmup_iteration = BenchmarkIteration::Warmup(i); + let _ = run_preparation_command(&warmup_iteration)?; let _ = self.executor.run_command_and_measure( self.command, - BenchmarkIteration::Warmup(i), + &warmup_iteration, None, output_policy, )?; - let _ = run_conclusion_command()?; + let _ = run_conclusion_command(warmup_iteration)?; if let Some(bar) = progress_bar.as_ref() { bar.inc(1) } @@ -234,7 +244,8 @@ impl<'a> Benchmark<'a> { None }; - let preparation_result = run_preparation_command()?; + let benchmark_iteration = BenchmarkIteration::Benchmark(0); + let preparation_result = run_preparation_command(&benchmark_iteration)?; let preparation_overhead = preparation_result.map_or(Time::zero(), |res| { res.time_wall_clock + self.executor.time_overhead() }); @@ -242,13 +253,13 @@ impl<'a> Benchmark<'a> { // Initial timing run let res = self.executor.run_command_and_measure( self.command, - BenchmarkIteration::Benchmark(0), + &benchmark_iteration, None, output_policy, )?; let success = res.exit_status.success(); - let conclusion_result = run_conclusion_command()?; + let conclusion_result = run_conclusion_command(benchmark_iteration)?; let conclusion_overhead = conclusion_result.map_or(Time::zero(), |res| { res.time_wall_clock + self.executor.time_overhead() }); @@ -289,7 +300,8 @@ impl<'a> Benchmark<'a> { // Gather statistics (perform the actual benchmark) for i in 0..count_remaining { - run_preparation_command()?; + let benchmark_iteration = BenchmarkIteration::Benchmark(i + 1); + run_preparation_command(&benchmark_iteration)?; let msg = { let t_wall_clock_mean = measurements.time_wall_clock_mean(); @@ -307,7 +319,7 @@ impl<'a> Benchmark<'a> { let res = self.executor.run_command_and_measure( self.command, - BenchmarkIteration::Benchmark(i + 1), + &benchmark_iteration, None, output_policy, )?; @@ -321,7 +333,7 @@ impl<'a> Benchmark<'a> { bar.inc(1) } - run_conclusion_command()?; + run_conclusion_command(benchmark_iteration)?; } if let Some(bar) = progress_bar.as_ref() { @@ -440,7 +452,11 @@ impl<'a> Benchmark<'a> { console_writeln!(io::stdout(), " ")?; } - self.run_cleanup_command(self.command.get_parameters().iter().cloned(), output_policy)?; + self.run_cleanup_command( + self.command.get_parameters().iter().cloned(), + output_policy, + executor::BenchmarkIteration::NonBenchmarkRun, + )?; Ok(BenchmarkResult { command: self.command.get_name(), diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 826bace..3e1d913 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1037,3 +1037,119 @@ fn windows_quote_before_quote_args() { .assert() .success(); } + +#[cfg(unix)] +#[test] +fn hyperfine_iteration_env_var_in_prepare_command() { + use tempfile::tempdir; + + let tempdir = tempdir().unwrap(); + let output_path = tempdir.path().join("iteration_output.txt"); + + // Write HYPERFINE_ITERATION value to a file during prepare + hyperfine() + .arg("--runs=2") + .arg("--warmup=1") + .arg(format!( + "--prepare=echo $HYPERFINE_ITERATION >> {}", + output_path.to_string_lossy() + )) + .arg("echo test") + .assert() + .success(); + + let contents = std::fs::read_to_string(output_path).unwrap(); + let lines: Vec<&str> = contents.lines().collect(); + + assert_eq!(lines.len(), 3); + assert_eq!(lines[0], "warmup-0"); + assert_eq!(lines[1], "0"); + assert_eq!(lines[2], "1"); +} + +#[cfg(windows)] +#[test] +fn hyperfine_iteration_env_var_in_prepare_command() { + use tempfile::tempdir; + + let tempdir = tempdir().unwrap(); + let output_path = tempdir.path().join("iteration_output.txt"); + + // Write HYPERFINE_ITERATION value to a file during prepare + hyperfine() + .arg("--runs=2") + .arg("--warmup=1") + .arg(format!( + "--prepare=echo %HYPERFINE_ITERATION% >> {}", + output_path.to_string_lossy() + )) + .arg("echo test") + .assert() + .success(); + + let contents = std::fs::read_to_string(output_path).unwrap(); + let lines: Vec = contents.lines().map(|l| l.trim().to_string()).collect(); + + assert_eq!(lines.len(), 3); + assert_eq!(lines[0], "warmup-0"); + assert_eq!(lines[1], "0"); + assert_eq!(lines[2], "1"); +} + +#[cfg(unix)] +#[test] +fn hyperfine_iteration_env_var_in_conclude_command() { + use tempfile::tempdir; + + let tempdir = tempdir().unwrap(); + let output_path = tempdir.path().join("iteration_output.txt"); + + // Write HYPERFINE_ITERATION value to a file during conclude + hyperfine() + .arg("--runs=2") + .arg("--warmup=1") + .arg(format!( + "--conclude=echo $HYPERFINE_ITERATION >> {}", + output_path.to_string_lossy() + )) + .arg("echo test") + .assert() + .success(); + + let contents = std::fs::read_to_string(output_path).unwrap(); + let lines: Vec<&str> = contents.lines().collect(); + + assert_eq!(lines.len(), 3); + assert_eq!(lines[0], "warmup-0"); + assert_eq!(lines[1], "0"); + assert_eq!(lines[2], "1"); +} + +#[cfg(windows)] +#[test] +fn hyperfine_iteration_env_var_in_conclude_command() { + use tempfile::tempdir; + + let tempdir = tempdir().unwrap(); + let output_path = tempdir.path().join("iteration_output.txt"); + + // Write HYPERFINE_ITERATION value to a file during conclude + hyperfine() + .arg("--runs=2") + .arg("--warmup=1") + .arg(format!( + "--conclude=echo %HYPERFINE_ITERATION% >> {}", + output_path.to_string_lossy() + )) + .arg("echo test") + .assert() + .success(); + + let contents = std::fs::read_to_string(output_path).unwrap(); + let lines: Vec = contents.lines().map(|l| l.trim().to_string()).collect(); + + assert_eq!(lines.len(), 3); + assert_eq!(lines[0], "warmup-0"); + assert_eq!(lines[1], "0"); + assert_eq!(lines[2], "1"); +} From 1eafcf4739892746d0221ac87df044a4d349fda4 Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 5 Oct 2026 12:38:53 +0200 Subject: [PATCH 2/3] Combine iteration environment variable integration tests --- tests/integration_tests.rs | 136 +++++++++---------------------------- 1 file changed, 31 insertions(+), 105 deletions(-) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 3e1d913..e6832b2 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -1038,118 +1038,44 @@ fn windows_quote_before_quote_args() { .success(); } -#[cfg(unix)] #[test] -fn hyperfine_iteration_env_var_in_prepare_command() { - use tempfile::tempdir; +fn hyperfine_iteration_env_var_in_prepare_and_conclude_commands() { + let tempdir = tempfile::tempdir().unwrap(); + let output_path = tempdir.path().join("iteration output.txt"); + let iteration = if cfg!(windows) { + "%HYPERFINE_ITERATION%" + } else { + "$HYPERFINE_ITERATION" + }; + let command = |phase| format!(r#"echo {phase}:{iteration} >> "iteration output.txt""#); - let tempdir = tempdir().unwrap(); - let output_path = tempdir.path().join("iteration_output.txt"); - - // Write HYPERFINE_ITERATION value to a file during prepare hyperfine() + .current_dir(tempdir.path()) .arg("--runs=2") .arg("--warmup=1") - .arg(format!( - "--prepare=echo $HYPERFINE_ITERATION >> {}", - output_path.to_string_lossy() - )) - .arg("echo test") + .arg("--prepare") + .arg(command("prepare")) + .arg(command("benchmark")) + .arg("--conclude") + .arg(command("conclude")) .assert() .success(); let contents = std::fs::read_to_string(output_path).unwrap(); - let lines: Vec<&str> = contents.lines().collect(); - - assert_eq!(lines.len(), 3); - assert_eq!(lines[0], "warmup-0"); - assert_eq!(lines[1], "0"); - assert_eq!(lines[2], "1"); -} - -#[cfg(windows)] -#[test] -fn hyperfine_iteration_env_var_in_prepare_command() { - use tempfile::tempdir; - - let tempdir = tempdir().unwrap(); - let output_path = tempdir.path().join("iteration_output.txt"); - - // Write HYPERFINE_ITERATION value to a file during prepare - hyperfine() - .arg("--runs=2") - .arg("--warmup=1") - .arg(format!( - "--prepare=echo %HYPERFINE_ITERATION% >> {}", - output_path.to_string_lossy() - )) - .arg("echo test") - .assert() - .success(); - - let contents = std::fs::read_to_string(output_path).unwrap(); - let lines: Vec = contents.lines().map(|l| l.trim().to_string()).collect(); - - assert_eq!(lines.len(), 3); - assert_eq!(lines[0], "warmup-0"); - assert_eq!(lines[1], "0"); - assert_eq!(lines[2], "1"); -} - -#[cfg(unix)] -#[test] -fn hyperfine_iteration_env_var_in_conclude_command() { - use tempfile::tempdir; - - let tempdir = tempdir().unwrap(); - let output_path = tempdir.path().join("iteration_output.txt"); - - // Write HYPERFINE_ITERATION value to a file during conclude - hyperfine() - .arg("--runs=2") - .arg("--warmup=1") - .arg(format!( - "--conclude=echo $HYPERFINE_ITERATION >> {}", - output_path.to_string_lossy() - )) - .arg("echo test") - .assert() - .success(); - - let contents = std::fs::read_to_string(output_path).unwrap(); - let lines: Vec<&str> = contents.lines().collect(); - - assert_eq!(lines.len(), 3); - assert_eq!(lines[0], "warmup-0"); - assert_eq!(lines[1], "0"); - assert_eq!(lines[2], "1"); -} - -#[cfg(windows)] -#[test] -fn hyperfine_iteration_env_var_in_conclude_command() { - use tempfile::tempdir; - - let tempdir = tempdir().unwrap(); - let output_path = tempdir.path().join("iteration_output.txt"); - - // Write HYPERFINE_ITERATION value to a file during conclude - hyperfine() - .arg("--runs=2") - .arg("--warmup=1") - .arg(format!( - "--conclude=echo %HYPERFINE_ITERATION% >> {}", - output_path.to_string_lossy() - )) - .arg("echo test") - .assert() - .success(); - - let contents = std::fs::read_to_string(output_path).unwrap(); - let lines: Vec = contents.lines().map(|l| l.trim().to_string()).collect(); - - assert_eq!(lines.len(), 3); - assert_eq!(lines[0], "warmup-0"); - assert_eq!(lines[1], "0"); - assert_eq!(lines[2], "1"); + // cmd.exe's echo includes the space before the redirection operator. + let lines: Vec<&str> = contents.lines().map(str::trim_end).collect(); + assert_eq!( + lines, + [ + "prepare:warmup-0", + "benchmark:warmup-0", + "conclude:warmup-0", + "prepare:0", + "benchmark:0", + "conclude:0", + "prepare:1", + "benchmark:1", + "conclude:1", + ] + ); } From 3558138ceaa195926620f52cdad234fa0fd36bdd Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 5 Oct 2026 12:40:33 +0200 Subject: [PATCH 3/3] Further simplifications --- src/benchmark/executor.rs | 13 +++++----- src/benchmark/mod.rs | 52 +++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/benchmark/executor.rs b/src/benchmark/executor.rs index 10dee7d..e450d40 100644 --- a/src/benchmark/executor.rs +++ b/src/benchmark/executor.rs @@ -15,6 +15,7 @@ use super::measurement::{Measurement, Measurements}; use anyhow::{bail, Context, Result}; +#[derive(Clone, Copy)] pub enum BenchmarkIteration { NonBenchmarkRun, Warmup(u64), @@ -36,7 +37,7 @@ pub trait Executor { fn run_command_and_measure( &self, command: &Command<'_>, - iteration: &BenchmarkIteration, + iteration: BenchmarkIteration, command_failure_action: Option, output_policy: &CommandOutputPolicy, ) -> Result; @@ -56,7 +57,7 @@ pub trait Executor { fn run_command_and_measure_common( mut command: std::process::Command, - iteration: &BenchmarkIteration, + iteration: BenchmarkIteration, command_failure_action: CmdFailureAction, command_input_policy: &CommandInputPolicy, command_output_policy: &CommandOutputPolicy, @@ -132,7 +133,7 @@ impl Executor for RawExecutor<'_> { fn run_command_and_measure( &self, command: &Command<'_>, - iteration: &BenchmarkIteration, + iteration: BenchmarkIteration, command_failure_action: Option, output_policy: &CommandOutputPolicy, ) -> Result { @@ -175,7 +176,7 @@ impl Executor for ShellExecutor<'_> { fn run_command_and_measure( &self, command: &Command<'_>, - iteration: &BenchmarkIteration, + iteration: BenchmarkIteration, command_failure_action: Option, output_policy: &CommandOutputPolicy, ) -> Result { @@ -230,7 +231,7 @@ impl Executor for ShellExecutor<'_> { // Just run the shell without any command let res = self.run_command_and_measure( &Command::new(None, ""), - &BenchmarkIteration::NonBenchmarkRun, + BenchmarkIteration::NonBenchmarkRun, None, &CommandOutputPolicy::Null, ); @@ -304,7 +305,7 @@ impl Executor for MockExecutor { fn run_command_and_measure( &self, command: &Command<'_>, - _iteration: &BenchmarkIteration, + _iteration: BenchmarkIteration, _command_failure_action: Option, _output_policy: &CommandOutputPolicy, ) -> Result { diff --git a/src/benchmark/mod.rs b/src/benchmark/mod.rs index e68323d..c1707cc 100644 --- a/src/benchmark/mod.rs +++ b/src/benchmark/mod.rs @@ -58,7 +58,7 @@ impl<'a> Benchmark<'a> { command: &Command<'_>, error_output: &'static str, output_policy: &CommandOutputPolicy, - iteration: &executor::BenchmarkIteration, + iteration: executor::BenchmarkIteration, ) -> Result { self.executor .run_command_and_measure( @@ -75,7 +75,6 @@ impl<'a> Benchmark<'a> { &self, parameters: impl IntoIterator>, output_policy: &CommandOutputPolicy, - iteration: executor::BenchmarkIteration, ) -> Result { let command = self .options @@ -87,7 +86,14 @@ impl<'a> Benchmark<'a> { Append ' || true' to the command if you are sure that this can be ignored."; Ok(command - .map(|cmd| self.run_intermediate_command(&cmd, error_output, output_policy, &iteration)) + .map(|cmd| { + self.run_intermediate_command( + &cmd, + error_output, + output_policy, + BenchmarkIteration::NonBenchmarkRun, + ) + }) .transpose()? .unwrap_or_default()) } @@ -97,7 +103,6 @@ impl<'a> Benchmark<'a> { &self, parameters: impl IntoIterator>, output_policy: &CommandOutputPolicy, - iteration: executor::BenchmarkIteration, ) -> Result { let command = self .options @@ -109,7 +114,14 @@ impl<'a> Benchmark<'a> { Append ' || true' to the command if you are sure that this can be ignored."; Ok(command - .map(|cmd| self.run_intermediate_command(&cmd, error_output, output_policy, &iteration)) + .map(|cmd| { + self.run_intermediate_command( + &cmd, + error_output, + output_policy, + BenchmarkIteration::NonBenchmarkRun, + ) + }) .transpose()? .unwrap_or_default()) } @@ -119,7 +131,7 @@ impl<'a> Benchmark<'a> { &self, command: &Command<'_>, output_policy: &CommandOutputPolicy, - iteration: &executor::BenchmarkIteration, + iteration: executor::BenchmarkIteration, ) -> Result { let error_output = "The preparation command terminated with a non-zero exit code. \ Append ' || true' to the command if you are sure that this can be ignored."; @@ -137,7 +149,7 @@ impl<'a> Benchmark<'a> { let error_output = "The conclusion command terminated with a non-zero exit code. \ Append ' || true' to the command if you are sure that this can be ignored."; - self.run_intermediate_command(command, error_output, output_policy, &iteration) + self.run_intermediate_command(command, error_output, output_policy, iteration) } /// Run the benchmark for a single command @@ -170,7 +182,7 @@ impl<'a> Benchmark<'a> { ) }); - let run_preparation_command = |iteration: &executor::BenchmarkIteration| { + let run_preparation_command = |iteration: executor::BenchmarkIteration| { preparation_command .as_ref() .map(|cmd| self.run_preparation_command(cmd, output_policy, iteration)) @@ -196,11 +208,7 @@ impl<'a> Benchmark<'a> { .transpose() }; - self.run_setup_command( - self.command.get_parameters().iter().cloned(), - output_policy, - executor::BenchmarkIteration::NonBenchmarkRun, - )?; + self.run_setup_command(self.command.get_parameters().iter().cloned(), output_policy)?; // Warmup phase if self.options.warmup_count > 0 { @@ -216,10 +224,10 @@ impl<'a> Benchmark<'a> { for i in 0..self.options.warmup_count { let warmup_iteration = BenchmarkIteration::Warmup(i); - let _ = run_preparation_command(&warmup_iteration)?; + let _ = run_preparation_command(warmup_iteration)?; let _ = self.executor.run_command_and_measure( self.command, - &warmup_iteration, + warmup_iteration, None, output_policy, )?; @@ -245,7 +253,7 @@ impl<'a> Benchmark<'a> { }; let benchmark_iteration = BenchmarkIteration::Benchmark(0); - let preparation_result = run_preparation_command(&benchmark_iteration)?; + let preparation_result = run_preparation_command(benchmark_iteration)?; let preparation_overhead = preparation_result.map_or(Time::zero(), |res| { res.time_wall_clock + self.executor.time_overhead() }); @@ -253,7 +261,7 @@ impl<'a> Benchmark<'a> { // Initial timing run let res = self.executor.run_command_and_measure( self.command, - &benchmark_iteration, + benchmark_iteration, None, output_policy, )?; @@ -301,7 +309,7 @@ impl<'a> Benchmark<'a> { // Gather statistics (perform the actual benchmark) for i in 0..count_remaining { let benchmark_iteration = BenchmarkIteration::Benchmark(i + 1); - run_preparation_command(&benchmark_iteration)?; + run_preparation_command(benchmark_iteration)?; let msg = { let t_wall_clock_mean = measurements.time_wall_clock_mean(); @@ -319,7 +327,7 @@ impl<'a> Benchmark<'a> { let res = self.executor.run_command_and_measure( self.command, - &benchmark_iteration, + benchmark_iteration, None, output_policy, )?; @@ -452,11 +460,7 @@ impl<'a> Benchmark<'a> { console_writeln!(io::stdout(), " ")?; } - self.run_cleanup_command( - self.command.get_parameters().iter().cloned(), - output_policy, - executor::BenchmarkIteration::NonBenchmarkRun, - )?; + self.run_cleanup_command(self.command.get_parameters().iter().cloned(), output_policy)?; Ok(BenchmarkResult { command: self.command.get_name(),