Skip to content
Myr

Show current time estimate, closes #7

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

authored by sharkdp · committed by sharkdp · parent 6dcd3fe · Browse files · 1 file+18 added−10 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+18 added−10 removed

  • other:+18 added−10 removed

1 file+18 added−10 removed

modified:src/main.rs+18 added-10 removed
72 unmodified lines
73/// Return a pre-configured progress bar74fn get_progress_bar(length: u64, msg: &str) -> ProgressBar {75 let progressbar_style = ProgressStyle::default_spinner()76 .tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏")77 .template(" {spinner} {msg:<28} {wide_bar} ETA {eta_precise}");77 .template(" {spinner} {msg:<30} {wide_bar} ETA {eta_precise}");7879 let bar = ProgressBar::new(length);80 bar.set_style(progressbar_style.clone());81 bar.enable_steady_tick(80);
41 unmodified lines
123 cmd: &str,124 shell_spawning_time: Second,125 options: &HyperfineOptions,126) -> io::Result<()> {127 // Helper function to compute corrected execution times128 let get_execution_time = |r: &CmdResult| -> Second {129 if r.execution_time_sec < shell_spawning_time {130 0.0131 } else {132 r.execution_time_sec - shell_spawning_time133 }134 };135136 println!(137 "{}{}: {}",138 White.bold().paint("Benchmark #"),139 White.bold().paint((num + 1).to_string()),
33 unmodified lines
173 results.push(res);174175 // Re-configure the progress bar176 bar.set_length(count);168 bar.set_message("Collecting statistics");177178 // Gather statistics179 for _ in 0..count {180 let msg = {181 let execution_times = results.iter().map(&get_execution_time);182 let mean = format!("{:.3} s", mean(execution_times));183 format!("Current estimate: {:.3}", Green.paint(mean))184 };185 bar.set_message(&msg);186187 let res = time_shell_command(cmd, options.ignore_failure)?;188 results.push(res);189 bar.inc(1);190 }191 bar.finish_and_clear();192193 // Compute statistical quantities179 let get_execution_time = |r: &CmdResult| -> Second {180 if r.execution_time_sec < shell_spawning_time {181 0.0182 } else {183 r.execution_time_sec - shell_spawning_time184 }185 };194187 // Iterator over (corrected) execution times195 // Corrected execution times196 let execution_times = results.iter().map(&get_execution_time);197198 let t_mean = mean(execution_times.clone());199 let t2_mean = mean(execution_times.clone().map(|t| t.powi(2)));
160 unmodified lines