Skip to content
Myr

Warmup count as u64 only

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent 2ab118d · Browse files · 1 file+14 added−11 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+14 added−11 removed

  • other:+14 added−11 removed

1 file+14 added−11 removed

modified:src/main.rs+14 added-11 removed
120 unmodified lines
121122 let mut results = vec![];123124 // Warmup phase125 if let Some(warmup_count) = options.warmup_count {126 let bar = get_progress_bar(warmup_count, "Performing warmup runs");125 if options.warmup_count > 0 {126 let bar = get_progress_bar(options.warmup_count, "Performing warmup runs");127128 for _ in 1..warmup_count {128 for _ in 1..options.warmup_count {129 bar.inc(1);130 let _ = time_shell_command(cmd);131 }132 bar.finish_and_clear();
92 unmodified lines
225/// Runs the benchmark for the given commands226fn run(commands: &Vec<&str>, options: &HyperfineOptions) -> io::Result<()> {227 let shell_spawning_time = mean_shell_spawning_time()?;228229 println!(230 "Mean shell spawning time: {:.3} ms",231 1e3 * shell_spawning_time232 );233229 // Run the benchmarks230 for cmd in commands {231 run_benchmark(&cmd, shell_spawning_time, &options)?;232 }
1 unmodified line
234 Ok(())235}236237pub struct HyperfineOptions {238 /// Number of warmup runs243 pub warmup_count: Option<u64>,239 pub warmup_count: u64,240241 /// Minimum number of benchmark runs242 pub min_runs: u64,243244 /// Minimum benchmarking time245 pub min_time_sec: Second,246}247248impl Default for HyperfineOptions {249 fn default() -> HyperfineOptions {250 HyperfineOptions {251 warmup_count: None,251 warmup_count: 0,252 min_runs: 10,253 min_time_sec: 3.0,254 }255 }
33 unmodified lines
289 let str_to_u64 = |n| u64::from_str_radix(n, 10).ok();290291 // Process command line options292 let mut options = HyperfineOptions::default();293 options.warmup_count = matches.value_of("warmup").and_then(&str_to_u64);293 options.warmup_count = matches294 .value_of("warmup")295 .and_then(&str_to_u64)296 .unwrap_or(0);297298 if let Some(min_runs) = matches.value_of("min-runs").and_then(&str_to_u64) {299 options.min_runs = cmp::max(1, min_runs);300 }
9 unmodified lines