Skip to content

Commit 6014771

Browse files
committed
Show standard deviation in progress message
1 parent 975fe10 commit 6014771

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/benchmark/mod.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,25 @@ impl<'a> Benchmark<'a> {
297297
for i in 0..count_remaining {
298298
run_preparation_command()?;
299299

300-
let msg = {
301-
let mean = format_duration(mean(&times_real), self.options.time_unit);
302-
format!("Current estimate: {}", mean.to_string().green())
303-
};
304-
305300
if let Some(bar) = progress_bar.as_ref() {
306-
bar.set_message(msg.to_owned())
301+
let msg = {
302+
let mean = mean(&times_real);
303+
let (mean_str, time_unit) = format_duration_unit(mean, self.options.time_unit);
304+
305+
if times_real.len() > 1 {
306+
let stddev = standard_deviation(&times_real, Some(mean));
307+
let stddev_str = format_duration(stddev, Some(time_unit));
308+
format!(
309+
"Current estimate: {} ± {}",
310+
mean_str.green(),
311+
stddev_str.cyan()
312+
)
313+
} else {
314+
format!("Current estimate: {}", mean_str.green())
315+
}
316+
};
317+
318+
bar.set_message(msg)
307319
}
308320

309321
let (res, status) = self.executor.run_command_and_measure(

0 commit comments

Comments
 (0)