mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-01 08:50:19 +00:00
Fix prepare and conclude behaviour and add tests.
This commit is contained in:
1 parent
9806ed7694
commit
d4749b015f
4 files changed
+306
-6
No files matched your search
@@ -61,6 +61,17 @@ fn fails_with_wrong_number_of_prepare_options() {
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
hyperfine()
|
||||
.arg("--runs=1")
|
||||
.arg("--prepare=echo ref")
|
||||
.arg("--prepare=echo a")
|
||||
.arg("--prepare=echo b")
|
||||
.arg("--reference=echo ref")
|
||||
.arg("echo a")
|
||||
.arg("echo b")
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
hyperfine()
|
||||
.arg("--runs=1")
|
||||
.arg("--prepare=echo a")
|
||||
@@ -73,6 +84,19 @@ fn fails_with_wrong_number_of_prepare_options() {
|
||||
.stderr(predicate::str::contains(
|
||||
"The '--prepare' option has to be provided",
|
||||
));
|
||||
|
||||
hyperfine()
|
||||
.arg("--runs=1")
|
||||
.arg("--prepare=echo a")
|
||||
.arg("--prepare=echo b")
|
||||
.arg("--reference=echo ref")
|
||||
.arg("echo a")
|
||||
.arg("echo b")
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(predicate::str::contains(
|
||||
"The '--prepare' option has to be provided",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -86,6 +110,17 @@ fn fails_with_wrong_number_of_conclude_options() {
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
hyperfine()
|
||||
.arg("--runs=1")
|
||||
.arg("--conclude=echo ref")
|
||||
.arg("--conclude=echo a")
|
||||
.arg("--conclude=echo b")
|
||||
.arg("--reference=echo ref")
|
||||
.arg("echo a")
|
||||
.arg("echo b")
|
||||
.assert()
|
||||
.success();
|
||||
|
||||
hyperfine()
|
||||
.arg("--runs=1")
|
||||
.arg("--conclude=echo a")
|
||||
@@ -98,6 +133,19 @@ fn fails_with_wrong_number_of_conclude_options() {
|
||||
.stderr(predicate::str::contains(
|
||||
"The '--conclude' option has to be provided",
|
||||
));
|
||||
|
||||
hyperfine()
|
||||
.arg("--runs=1")
|
||||
.arg("--conclude=echo a")
|
||||
.arg("--conclude=echo b")
|
||||
.arg("--reference=echo ref")
|
||||
.arg("echo a")
|
||||
.arg("echo b")
|
||||
.assert()
|
||||
.failure()
|
||||
.stderr(predicate::str::contains(
|
||||
"The '--conclude' option has to be provided",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -413,6 +461,20 @@ fn shows_benchmark_comparison_with_relative_times() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shows_benchmark_comparison_relative_to_reference() {
|
||||
hyperfine_debug()
|
||||
.arg("--reference=sleep 2.0")
|
||||
.arg("sleep 1.0")
|
||||
.arg("sleep 3.0")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(
|
||||
predicate::str::contains("2.00 ± 0.00 times slower")
|
||||
.and(predicate::str::contains("1.50 ± 0.00 times faster")),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn performs_all_benchmarks_in_parameter_scan() {
|
||||
hyperfine_debug()
|
||||
@@ -434,6 +496,29 @@ fn performs_all_benchmarks_in_parameter_scan() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn performs_reference_and_all_benchmarks_in_parameter_scan() {
|
||||
hyperfine_debug()
|
||||
.arg("--reference=sleep 25")
|
||||
.arg("--parameter-scan")
|
||||
.arg("time")
|
||||
.arg("30")
|
||||
.arg("45")
|
||||
.arg("--parameter-step-size")
|
||||
.arg("5")
|
||||
.arg("sleep {time}")
|
||||
.assert()
|
||||
.success()
|
||||
.stdout(
|
||||
predicate::str::contains("Benchmark 1: sleep 25")
|
||||
.and(predicate::str::contains("Benchmark 2: sleep 30"))
|
||||
.and(predicate::str::contains("Benchmark 3: sleep 35"))
|
||||
.and(predicate::str::contains("Benchmark 4: sleep 40"))
|
||||
.and(predicate::str::contains("Benchmark 5: sleep 45"))
|
||||
.and(predicate::str::contains("Benchmark 6: sleep 50").not()),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn intermediate_results_are_not_exported_to_stdout() {
|
||||
hyperfine_debug()
|
||||
|
||||
Reference in new issue
Block a user