Skip to content
Myr

Remove more function arguments

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 39c7736 · Browse files · 1 file+51 added−38 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+51 added−38 removed

  • other:+51 added−38 removed

1 file+51 added−38 removed

modified:src/benchmark/scheduler.rs+51 added-38 removed
14 unmodified lines
15use crate::outlier_detection::{modified_zscores, OUTLIER_THRESHOLD};16use crate::output::format::{format_duration, format_duration_unit};17use crate::output::progress_bar::get_progress_bar;18use crate::output::warnings::Warnings;19use crate::parameter::ParameterNameAndValue;20use crate::shell::execute_and_time;21use crate::timer::wallclocktimer::WallClockTimer;22use crate::timer::{TimerStart, TimerStop};23use crate::util::exit_code::extract_exit_code;
158 unmodified lines
182 )?;183184 for (num, cmd) in self.commands.iter().enumerate() {185 self.results185 .push(self.run_benchmark(num, cmd, shell_spawning_time, self.options)?);186 .push(self.run_benchmark(num, cmd, shell_spawning_time)?);187188 // We export (all results so far) after each individual benchmark, because189 // we would risk losing all results if a later benchmark fails.190 self.export_manager
68 unmodified lines
259 })260 }261262 /// Run the command specified by `--setup`.262 fn run_setup_command(&self, command: &Option<Command<'_>>) -> Result<TimingResult> {263 fn run_setup_command(264 &self,265 parameters: impl IntoIterator<Item = ParameterNameAndValue<'a>>,266 ) -> Result<TimingResult> {267 let command = self268 .options269 .setup_command270 .as_ref()271 .map(|setup_command| Command::new_parametrized(None, setup_command, parameters));272273 let error_output = "The setup command terminated with a non-zero exit code. \274 Append ' || true' to the command if you are sure that this can be ignored.";275266 self.run_intermediate_command(command, error_output)276 self.run_intermediate_command(&command, error_output)277 }278279 /// Run the command specified by `--prepare`.280 fn run_preparation_command(&self, command: &Option<Command<'_>>) -> Result<TimingResult> {
16 unmodified lines
297 &self,298 num: usize,299 cmd: &Command<'_>,300 shell_spawning_time: TimingResult,291 options: &Options,301 ) -> Result<BenchmarkResult> {302 let command_name = cmd.get_name();294 if options.output_style != OutputStyleOption::Disabled {303 if self.options.output_style != OutputStyleOption::Disabled {304 println!(305 "{}{}: {}",306 "Benchmark ".bold(),307 (num + 1).to_string().bold(),
7 unmodified lines
315 let mut exit_codes: Vec<Option<i32>> = vec![];316 let mut all_succeeded = true;317318 // Run init command310 let prepare_cmd = options.preparation_command.as_ref().map(|values| {319 let prepare_cmd = self.options.preparation_command.as_ref().map(|values| {320 let preparation_command = if values.len() == 1 {321 &values[0]322 } else {323 &values[num]
4 unmodified lines
328 cmd.get_parameters().iter().cloned(),329 )330 });331323 // Run setup command324 let setup_cmd = options.setup_command.as_ref().map(|setup_command| {325 Command::new_parametrized(None, setup_command, cmd.get_parameters().iter().cloned())326 });327 self.run_setup_command(&setup_cmd)?;332 self.run_setup_command(cmd.get_parameters().iter().cloned())?;333334 // Warmup phase330 if options.warmup_count > 0 {331 let progress_bar = if options.output_style != OutputStyleOption::Disabled {335 if self.options.warmup_count > 0 {336 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {337 Some(get_progress_bar(333 options.warmup_count,338 self.options.warmup_count,339 "Performing warmup runs",335 options.output_style,340 self.options.output_style,341 ))342 } else {343 None344 };345341 for _ in 0..options.warmup_count {346 for _ in 0..self.options.warmup_count {347 let _ = self.run_preparation_command(&prepare_cmd)?;348 let _ = time_shell_command(344 &options.shell,349 &self.options.shell,350 cmd,346 options.command_output_policy,347 options.command_failure_action,351 self.options.command_output_policy,352 self.options.command_failure_action,353 None,354 )?;355 if let Some(bar) = progress_bar.as_ref() {356 bar.inc(1)
4 unmodified lines
361 }362 }363364 // Set up progress bar (and spinner for initial measurement)360 let progress_bar = if options.output_style != OutputStyleOption::Disabled {365 let progress_bar = if self.options.output_style != OutputStyleOption::Disabled {366 Some(get_progress_bar(362 options.run_bounds.min,367 self.options.run_bounds.min,368 "Initial time measurement",364 options.output_style,369 self.options.output_style,370 ))371 } else {372 None373 };
1 unmodified line
375 let prepare_result = self.run_preparation_command(&prepare_cmd)?;376377 // Initial timing run378 let (res, status) = time_shell_command(374 &options.shell,379 &self.options.shell,380 cmd,376 options.command_output_policy,377 options.command_failure_action,381 self.options.command_output_policy,382 self.options.command_failure_action,383 Some(shell_spawning_time),384 )?;385 let success = status.success();386387 // Determine number of benchmark runs383 let runs_in_min_time = (options.min_benchmarking_time388 let runs_in_min_time = (self.options.min_benchmarking_time389 / (res.time_real + prepare_result.time_real + shell_spawning_time.time_real))390 as u64;391392 let count = {388 let min = cmp::max(runs_in_min_time, options.run_bounds.min);393 let min = cmp::max(runs_in_min_time, self.options.run_bounds.min);394390 options395 self.options396 .run_bounds397 .max398 .as_ref()399 .map(|max| cmp::min(min, *max))
22 unmodified lines
422 for _ in 0..count_remaining {423 self.run_preparation_command(&prepare_cmd)?;424425 let msg = {421 let mean = format_duration(mean(&times_real), options.time_unit);426 let mean = format_duration(mean(&times_real), self.options.time_unit);427 format!("Current estimate: {}", mean.to_string().green())428 };429430 if let Some(bar) = progress_bar.as_ref() {431 bar.set_message(msg.to_owned())432 }433434 let (res, status) = time_shell_command(430 &options.shell,435 &self.options.shell,436 cmd,432 options.command_output_policy,433 options.command_failure_action,437 self.options.command_output_policy,438 self.options.command_failure_action,439 Some(shell_spawning_time),440 )?;441 let success = status.success();442
28 unmodified lines
471 let user_mean = mean(&times_user);472 let system_mean = mean(&times_system);473474 // Formatting and console output470 let (mean_str, time_unit) = format_duration_unit(t_mean, options.time_unit);475 let (mean_str, time_unit) = format_duration_unit(t_mean, self.options.time_unit);476 let min_str = format_duration(t_min, Some(time_unit));477 let max_str = format_duration(t_max, Some(time_unit));478 let num_str = format!("{} runs", t_num);479480 let user_str = format_duration(user_mean, Some(time_unit));481 let system_str = format_duration(system_mean, Some(time_unit));482478 if options.output_style != OutputStyleOption::Disabled {483 if self.options.output_style != OutputStyleOption::Disabled {484 if times_real.len() == 1 {485 println!(486 " Time ({} ≡): {:>8} {:>8} [User: {}, System: {}]",487 "abs".green().bold(),
54 unmodified lines
542 eprintln!(" {}: {}", "Warning".yellow(), warning);543 }544 }545541 if options.output_style != OutputStyleOption::Disabled {546 if self.options.output_style != OutputStyleOption::Disabled {547 println!(" ");548 }549550 // Run cleanup command546 let cleanup_cmd = options.cleanup_command.as_ref().map(|cleanup_command| {547 Command::new_parametrized(None, cleanup_command, cmd.get_parameters().iter().cloned())548 });551 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)?;563564 Ok(BenchmarkResult {565 command: command_name,
17 unmodified lines