Move functionality into run_cleanup_command
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Peter · committed by David Peter · parent ffa1c0e · Browse files · 1 file·+19 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+19 added−23 removed
- other:+19 added−23 removed
Provenance
- Commit
fa2eaaa- Tree
1fc3dd7- Author
David Peter <mail@david-peter.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
ffa1c0e
1 file changed+19 added−23 removed
modified:src/benchmark/scheduler.rs+19 added-23 removed
274 unmodified lines275 276 self.run_intermediate_command(&command, error_output)277 }278 279+ /// Run the command specified by `--cleanup`.280+ fn run_cleanup_command(281+ &self,282+ parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,283+ ) -> Result<TimingResult> {284+ let command = self285+ .options286+ .cleanup_command287+ .as_ref()288+ .map(|cleanup_command| Command::new_parametrized(None, cleanup_command, parameters));289+290+ let error_output = "The cleanup command terminated with a non-zero exit code. \291+ Append ' || true' to the command if you are sure that this can be ignored.";292+293+ self.run_intermediate_command(&command, error_output)294+ }295+296 /// Run the command specified by `--prepare`.297 fn run_preparation_command(&self, command: &Option<Command<'_>>) -> Result<TimingResult> {298 let error_output = "The preparation command terminated with a non-zero exit code. \299 Append ' || true' to the command if you are sure that this can be ignored.";300 301 self.run_intermediate_command(command, error_output)302 }303 287- /// Run the command specified by `--cleanup`.288- fn run_cleanup_command(&self, command: &Option<Command<'_>>) -> Result<TimingResult> {289- let error_output = "The cleanup command terminated with a non-zero exit code. \290- Append ' || true' to the command if you are sure that this can be ignored.";291-292- self.run_intermediate_command(command, error_output)293- }294-304 /// Run the benchmark for a single shell command305 pub fn run_benchmark(306 &self,307 num: usize,15 unmodified lines323 let mut times_system: Vec<Second> = vec![];324 let mut exit_codes: Vec<Option<i32>> = vec![];325 let mut all_succeeded = true;326 318- // Run init command327 let prepare_cmd = self.options.preparation_command.as_ref().map(|values| {328 let preparation_command = if values.len() == 1 {329 &values[0]330 } else {94 unmodified lines425 if let Some(bar) = progress_bar.as_ref() {426 bar.inc(1)427 }428 421- // Gather statistics429+ // Gather statistics (perform the actual benchmark)430 for _ in 0..count_remaining {431 self.run_preparation_command(&prepare_cmd)?;432 433 let msg = {120 unmodified lines554 if self.options.output_style != OutputStyleOption::Disabled {555 println!(" ");556 }557 550- // Run cleanup command551- let cleanup_cmd = self552- .options553- .cleanup_command554- .as_ref()555- .map(|cleanup_command| {556- Command::new_parametrized(557- None,558- cleanup_command,559- cmd.get_parameters().iter().cloned(),560- )561- });562- self.run_cleanup_command(&cleanup_cmd)?;558+ self.run_cleanup_command(cmd.get_parameters().iter().cloned())?;559 560 Ok(BenchmarkResult {561 command: command_name,562 mean: t_mean,16 unmodified lines