Skip to content
Myr

Change message for identical time and add test for it

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

authored by Jan-Eric Nitschke · committed by David Peter · parent 9134337 · Browse files · 2 files+39 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

2 files+39 added−10 removed

  • tests:+18 added−0 removed
  • other:+21 added−10 removed

2 files+39 added−10 removed

modified:src/benchmark/scheduler.rs+21 added-10 removed
94 unmodified lines
95 reference.result.command_with_unused_parameters.cyan()96 );9798 for item in others {99 let stddev = if let Some(stddev) = item.relative_speed_stddev {100 format!(" ± {}", format!("{:.2}", stddev).green())101 } else {102 "".into()103 };104 let comparator = match item.relative_ordering {100 Ordering::Less => "slower",101 Ordering::Greater => "faster",102 Ordering::Equal => "as fast",105 Ordering::Less => format!(106 "{}{} times slower than",107 format!("{:8.2}", item.relative_speed).bold().green(),108 stddev109 ),110 Ordering::Greater => format!(111 "{}{} times faster than",112 format!("{:8.2}", item.relative_speed).bold().green(),113 stddev114 ),115 Ordering::Equal => format!(116 " As fast ({}{}) as",117 format!("{:.2}", item.relative_speed).bold().green(),118 stddev119 ),120 };121 println!(105 "{}{} times {} than {}",106 format!("{:8.2}", item.relative_speed).bold().green(),107 if let Some(stddev) = item.relative_speed_stddev {108 format!(" ± {}", format!("{stddev:.2}").green())109 } else {110 "".into()111 },122 "{} {}",123 comparator,124 &item.result.command_with_unused_parameters.magenta()125 );126 }
38 unmodified lines
modified:tests/integration_tests.rs+18 added
460 unmodified lines
461 );462}463464#[test]465fn shows_benchmark_comparison_with_same_time() {466 hyperfine_debug()467 .arg("--command-name=A")468 .arg("--command-name=B")469 .arg("sleep 1.0")470 .arg("sleep 1.0")471 .arg("sleep 2.0")472 .arg("sleep 1000.0")473 .assert()474 .success()475 .stdout(476 predicate::str::contains("As fast (1.00 ± 0.00) as")477 .and(predicate::str::contains("2.00 ± 0.00 times faster"))478 .and(predicate::str::contains("1000.00 ± 0.00 times faster")),479 );480}481482#[test]483fn shows_benchmark_comparison_relative_to_reference() {484 hyperfine_debug()485 .arg("--reference=sleep 2.0")486 .arg("sleep 1.0")
148 unmodified lines