summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorevan <github@evan.lol>2022-04-22 14:43:22 +0300
committerGitHub <noreply@github.com>2022-04-22 13:43:22 +0200
commit6fad5c33c9dd51a2cb2c1ba1be5312f46835b6c4 (patch)
tree00380f82137289f06edd5bbaffa824027650b403
parent57f7e07c13a1a692602022af4fc32c6ac352bb72 (diff)
fix(bench): reset reporter context (#14360)
This commit fixes previous file benchmarks leaking into the next file benchmarks summary.
-rw-r--r--cli/tests/integration/bench_tests.rs6
-rw-r--r--cli/tests/testdata/bench/multifile_summary.out37
-rw-r--r--cli/tools/bench.rs4
3 files changed, 47 insertions, 0 deletions
diff --git a/cli/tests/integration/bench_tests.rs b/cli/tests/integration/bench_tests.rs
index 928f08bea..c646691dc 100644
--- a/cli/tests/integration/bench_tests.rs
+++ b/cli/tests/integration/bench_tests.rs
@@ -75,6 +75,12 @@ itest!(only {
output: "bench/only.out",
});
+itest!(multifile_summary {
+ args: "bench --unstable bench/pass.ts bench/group_baseline.ts",
+ exit_code: 0,
+ output: "bench/multifile_summary.out",
+});
+
itest!(no_check {
args: "bench --unstable --no-check bench/no_check.ts",
exit_code: 1,
diff --git a/cli/tests/testdata/bench/multifile_summary.out b/cli/tests/testdata/bench/multifile_summary.out
new file mode 100644
index 000000000..5811e473b
--- /dev/null
+++ b/cli/tests/testdata/bench/multifile_summary.out
@@ -0,0 +1,37 @@
+Check [WILDCARD]/bench/pass.ts
+Check [WILDCARD]/bench/group_baseline.ts
+cpu: [WILDCARD]
+runtime: deno [WILDCARD] ([WILDCARD])
+
+[WILDCARD]/bench/pass.ts
+benchmark time (avg) (min … max) p75 p99 p995
+------------------------------------------------- -----------------------------
+bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench1 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench4 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench5 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench6 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench7 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench8 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+bench9 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+[WILDCARD]/bench/group_baseline.ts
+benchmark time (avg) (min … max) p75 p99 p995
+---------------------------------------------------- -----------------------------
+noop [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+noop2 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+summary
+ noo[WILDCARD]
+ [WILDCARD]x times [WILDCARD] than noo[WILDCARD]
+
+noop3 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+parse url 2x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+parse url 6x [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
+
+summary
+ parse url 2x
+ [WILDCARD]x times slower than noop3
+ [WILDCARD]x times faster than parse url 6x
diff --git a/cli/tools/bench.rs b/cli/tools/bench.rs
index 0947c2647..9de449d2b 100644
--- a/cli/tools/bench.rs
+++ b/cli/tools/bench.rs
@@ -178,6 +178,10 @@ impl BenchReporter for ConsoleReporter {
use std::sync::atomic::Ordering;
static FIRST_PLAN: AtomicBool = AtomicBool::new(true);
+ self.group = None;
+ self.baseline = None;
+ self.name = String::new();
+ self.group_measurements.clear();
self.options = Some(mitata::reporter::Options::new(
&plan.names.iter().map(|x| x.as_str()).collect::<Vec<&str>>(),
));