Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bench): Fix group header printing logic + don't filter out the warmup benchmark #23083

Merged
merged 3 commits into from Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/tools/bench/mod.rs
Expand Up @@ -233,7 +233,7 @@ async fn bench_specifier_inner(
let benchmarks = if used_only { only } else { no_only };
let mut benchmarks = benchmarks
.into_iter()
.filter(|(d, _)| filter.includes(&d.name) && !d.ignore)
.filter(|(d, _)| d.warmup || filter.includes(&d.name) && !d.ignore)
.collect::<Vec<_>>();
let mut groups = IndexSet::<Option<String>>::new();
// make sure ungrouped benchmarks are placed above grouped
Expand Down
11 changes: 1 addition & 10 deletions cli/tools/bench/reporters.rs
Expand Up @@ -99,7 +99,6 @@ impl BenchReporter for JsonReporter {
pub struct ConsoleReporter {
name: String,
show_output: bool,
has_ungrouped: bool,
group: Option<String>,
baseline: bool,
group_measurements: Vec<(BenchDescription, BenchStats)>,
Expand All @@ -114,7 +113,6 @@ impl ConsoleReporter {
options: None,
baseline: false,
name: String::new(),
has_ungrouped: false,
group_measurements: Vec::new(),
}
}
Expand Down Expand Up @@ -173,18 +171,11 @@ impl BenchReporter for ConsoleReporter {
self.name = desc.name.clone();

match &desc.group {
None => {
self.has_ungrouped = true;
}
None => {}

Some(group) => {
if self.group.is_none() || group != self.group.as_ref().unwrap() {
self.report_group_summary();
}

if (self.group.is_none() && self.has_ungrouped)
|| (self.group.is_some() && self.group_measurements.is_empty())
{
println!("{} {}", colors::gray("group"), colors::green(group));
}

Expand Down
5 changes: 5 additions & 0 deletions tests/specs/bench/filter_group_header/__test__.jsonc
@@ -0,0 +1,5 @@
// Regression test for https://github.com/denoland/deno/issues/23053
{
"args": "bench main.ts --filter=G",
"output": "main.out"
}
13 changes: 13 additions & 0 deletions tests/specs/bench/filter_group_header/main.out
@@ -0,0 +1,13 @@
Check [WILDCARD]
cpu: [WILDCARD]
runtime: [WILDCARD]

[WILDCARD]
benchmark time (avg) iter/s (min … max) p75 p99 p995
--------------------------------------------------------------- -----------------------------

group G1
G1-B [WILDCARD]

group G2
G2-B [WILDCARD]
11 changes: 11 additions & 0 deletions tests/specs/bench/filter_group_header/main.ts
@@ -0,0 +1,11 @@
Deno.bench({
group: "G1",
name: "G1-B",
fn() {},
});

Deno.bench({
group: "G2",
name: "G2-B",
fn() {},
});