Skip to content
Myr

Restructure run_intermediate_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 f4ef945 · Browse files · 1 file+32 added−24 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+32 added−24 removed

  • other:+32 added−24 removed

1 file+32 added−24 removed

modified:src/benchmark/scheduler.rs+32 added-24 removed
236 unmodified lines
237 }238239 fn run_intermediate_command(240 &self,241 command: &Option<Command<'_>>,241 command: &Command<'_>,242 error_output: &'static str,243 ) -> Result<TimingResult> {244 if let Some(ref cmd) = command {245 let res = time_shell_command(246 &self.options.shell,247 cmd,248 self.options.command_output_policy,249 CmdFailureAction::RaiseError,250 None,251 );252 if res.is_err() {253 bail!(error_output);244 let res = time_shell_command(245 &self.options.shell,246 command,247 self.options.command_output_policy,248 CmdFailureAction::RaiseError,249 None,250 );251 if res.is_err() {252 bail!(error_output);254 }255 return res.map(|r| r.0);253 }257 Ok(TimingResult {258 ..Default::default()259 })254 return res.map(|r| r.0);255 }256257 /// Run the command specified by `--setup`.258 fn run_setup_command(
8 unmodified lines
267268 let error_output = "The setup command terminated with a non-zero exit code. \269 Append ' || true' to the command if you are sure that this can be ignored.";270276 self.run_intermediate_command(&command, error_output)271 Ok(command272 .map(|cmd| self.run_intermediate_command(&cmd, error_output))273 .transpose()?274 .unwrap_or_default())275 }276277 /// Run the command specified by `--cleanup`.278 fn run_cleanup_command(
8 unmodified lines
287288 let error_output = "The cleanup command terminated with a non-zero exit code. \289 Append ' || true' to the command if you are sure that this can be ignored.";290293 self.run_intermediate_command(&command, error_output)291 Ok(command292 .map(|cmd| self.run_intermediate_command(&cmd, error_output))293 .transpose()?294 .unwrap_or_default())295 }296297 /// Run the command specified by `--prepare`.297 fn run_preparation_command(&self, command: &Option<Command<'_>>) -> Result<TimingResult> {298 fn run_preparation_command(&self, command: &Command<'_>) -> Result<TimingResult> {299 let error_output = "The preparation command terminated with a non-zero exit code. \300 Append ' || true' to the command if you are sure that this can be ignored.";301302 self.run_intermediate_command(command, error_output)
21 unmodified lines
324 let mut times_system: Vec<Second> = vec![];325 let mut exit_codes: Vec<Option<i32>> = vec![];326 let mut all_succeeded = true;327327 let prepare_cmd = self.options.preparation_command.as_ref().map(|values| {328 let preparation_command = self.options.preparation_command.as_ref().map(|values| {329 let preparation_command = if values.len() == 1 {330 &values[0]331 } else {332 &values[benchmark_number]
3 unmodified lines
336 preparation_command,337 command.get_parameters().iter().cloned(),338 )339 });340 let run_preparation_command = || {341 if let Some(ref cmd) = preparation_command {342 self.run_preparation_command(cmd)343 } else {344 Ok(TimingResult::default())345 }346 };347348 self.run_setup_command(command.get_parameters().iter().cloned())?;349350 // Warmup phase
8 unmodified lines
359 None360 };361362 for _ in 0..self.options.warmup_count {355 let _ = self.run_preparation_command(&prepare_cmd)?;363 let _ = run_preparation_command()?;364 let _ = time_shell_command(365 &self.options.shell,366 command,367 self.options.command_output_policy,
19 unmodified lines
387 } else {388 None389 };390383 let prepare_result = self.run_preparation_command(&prepare_cmd)?;391 let preparation_result = run_preparation_command()?;392393 // Initial timing run394 let (res, status) = time_shell_command(395 &self.options.shell,
5 unmodified lines
401 let success = status.success();402403 // Determine number of benchmark runs404 let runs_in_min_time = (self.options.min_benchmarking_time397 / (res.time_real + prepare_result.time_real + shell_spawning_time.time_real))405 / (res.time_real + preparation_result.time_real + shell_spawning_time.time_real))406 as u64;407408 let count = {409 let min = cmp::max(runs_in_min_time, self.options.run_bounds.min);
25 unmodified lines
435 }436437 // Gather statistics (perform the actual benchmark)438 for _ in 0..count_remaining {431 self.run_preparation_command(&prepare_cmd)?;439 run_preparation_command()?;440441 let msg = {442 let mean = format_duration(mean(&times_real), self.options.time_unit);443 format!("Current estimate: {}", mean.to_string().green())
143 unmodified lines