mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-08-16 17:30:21 +03:00
Change message for identical time and add test for it
This commit is contained in:
parent
f459aeeddf
commit
15e7fe3147
@ -96,19 +96,30 @@ impl<'a> Scheduler<'a> {
|
||||
);
|
||||
|
||||
for item in others {
|
||||
let comparator = match item.relative_ordering {
|
||||
Ordering::Less => "slower",
|
||||
Ordering::Greater => "faster",
|
||||
Ordering::Equal => "as fast",
|
||||
};
|
||||
println!(
|
||||
"{}{} times {} than {}",
|
||||
format!("{:8.2}", item.relative_speed).bold().green(),
|
||||
if let Some(stddev) = item.relative_speed_stddev {
|
||||
format!(" ± {}", format!("{stddev:.2}").green())
|
||||
let stddev = if let Some(stddev) = item.relative_speed_stddev {
|
||||
format!(" ± {}", format!("{:.2}", stddev).green())
|
||||
} else {
|
||||
"".into()
|
||||
},
|
||||
};
|
||||
let comparator = match item.relative_ordering {
|
||||
Ordering::Less => format!(
|
||||
"{}{} times slower than",
|
||||
format!("{:8.2}", item.relative_speed).bold().green(),
|
||||
stddev
|
||||
),
|
||||
Ordering::Greater => format!(
|
||||
"{}{} times faster than",
|
||||
format!("{:8.2}", item.relative_speed).bold().green(),
|
||||
stddev
|
||||
),
|
||||
Ordering::Equal => format!(
|
||||
" As fast ({}{}) as",
|
||||
format!("{:.2}", item.relative_speed).bold().green(),
|
||||
stddev
|
||||
),
|
||||
};
|
||||
println!(
|
||||
"{} {}",
|
||||
comparator,
|
||||
&item.result.command_with_unused_parameters.magenta()
|
||||
);
|
||||
|
@ -461,6 +461,24 @@ fn shows_benchmark_comparison_with_relative_times() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shows_benchmark_comparison_with_same_time() {
|
||||
hyperfine_debug()
|
||||
.arg("--command-name=A")
|
||||
.arg("--command-name=B")
|
||||
.arg("sleep 1.0")
|
||||
.arg("sleep 1.0")
|
||||
.arg("sleep 2.0")
|
||||
.arg("sleep 1000.0")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(
|
||||
predicate::str::contains("As fast (1.00 ± 0.00) as")
|
||||
.and(predicate::str::contains("2.00 ± 0.00 times faster"))
|
||||
.and(predicate::str::contains("1000.00 ± 0.00 times faster")),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shows_benchmark_comparison_relative_to_reference() {
|
||||
hyperfine_debug()
|
||||
|
Loading…
Reference in New Issue
Block a user