Skip to content

Commit aedb577

Browse files
committed
Give bench_local the option to run stable benchmarks
1 parent 2d336b1 commit aedb577

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

collector/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ The following options alter the behaviour of the `bench_local` subcommand.
123123
- `--exclude <EXCLUDE>`: this is used to run a subset of the benchmarks. The
124124
argument is a comma-separated list of benchmark prefixes. When this option is
125125
specified, a benchmark is excluded from the run if its name matches one of
126-
the given prefixes.
126+
the given prefixes. You can also specify `primary`, `secondary` and `stable`
127+
to filter on the category of benchmarks. `rust-timer` does not run `stable`
128+
benchmarks on PRs.
127129
- `--exclude-suffix <EXCLUDE>`: this is used to run a subset of the benchmarks. The
128130
argument is a comma-separated list of benchmark suffixes. When this option is
129131
specified, a benchmark is excluded from the run if its name matches one of
@@ -134,7 +136,9 @@ The following options alter the behaviour of the `bench_local` subcommand.
134136
- `--include <INCLUDE>`: the inverse of `--exclude`. The argument is a
135137
comma-separated list of benchmark prefixes. When this option is specified, a
136138
benchmark is included in the run only if its name matches one of the given
137-
prefixes.
139+
prefixes. You can also specify `primary`, `secondary` and `stable` to filter
140+
on the category of benchmarks. `rust-timer` only runs `--include primary,secondary`
141+
on PRs.
138142
- `--profiles <PROFILES>`: the profiles to be benchmarked. The possible choices
139143
are one or more (comma-separated) of `Check`, `Debug`, `Doc`, `Opt`, and
140144
`All`. The default is `Check,Debug,Opt`.

collector/src/bin/collector.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,12 @@ fn main_result() -> anyhow::Result<i32> {
899899
target_triple,
900900
)?;
901901

902-
let mut benchmarks = get_compile_benchmarks(
902+
let benchmarks = get_compile_benchmarks(
903903
&compile_benchmark_dir,
904904
local.include.as_deref(),
905905
local.exclude.as_deref(),
906906
local.exclude_suffix.as_deref(),
907907
)?;
908-
benchmarks.retain(|b| b.category().is_primary_or_secondary());
909908

910909
let artifact_id = ArtifactId::Tag(toolchain.id.clone());
911910
let mut conn = rt.block_on(pool.connection());

collector/src/compile/benchmark/mod.rs

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,28 +468,57 @@ pub fn get_compile_benchmarks(
468468
let mut excludes = to_hashmap(exclude);
469469
let mut exclude_suffixes = to_hashmap(exclude_suffix);
470470

471+
let mut include_primaries = false;
472+
let mut include_secondaries = false;
473+
let mut include_stables = false;
474+
if let Some(includes) = includes.as_mut() {
475+
include_primaries = includes.remove(&"primary").is_some();
476+
include_secondaries = includes.remove(&"secondary").is_some();
477+
include_stables = includes.remove(&"stable").is_some();
478+
}
479+
let mut exclude_primaries = false;
480+
let mut exclude_secondaries = false;
481+
let mut exclude_stables = false;
482+
if let Some(excludes) = excludes.as_mut() {
483+
exclude_primaries = excludes.remove(&"primary").is_some();
484+
exclude_secondaries = excludes.remove(&"secondary").is_some();
485+
exclude_stables = excludes.remove(&"stable").is_some();
486+
}
487+
471488
for (path, name) in paths {
472489
let mut skip = false;
490+
let b = Benchmark::new(name, path)?;
473491

474492
let name_matches_prefix = |prefixes: &mut HashMap<&str, usize>| {
475-
substring_matches(prefixes, |prefix| name.starts_with(prefix))
493+
substring_matches(prefixes, |prefix| b.name.0.starts_with(prefix))
476494
};
477495

496+
if include.is_none() && exclude.is_none() && b.category() == Category::Stable {
497+
// Common case: don't run the stable benchmarks.
498+
continue;
499+
}
500+
478501
if let Some(includes) = includes.as_mut() {
479-
skip |= !name_matches_prefix(includes);
502+
skip |= !(name_matches_prefix(includes)
503+
|| (include_primaries && b.category() == Category::Primary)
504+
|| (include_secondaries && b.category() == Category::Secondary)
505+
|| (include_stables && b.category() == Category::Stable));
480506
}
481507
if let Some(excludes) = excludes.as_mut() {
482-
skip |= name_matches_prefix(excludes);
508+
skip |= name_matches_prefix(excludes)
509+
|| (exclude_primaries && b.category() == Category::Primary)
510+
|| (exclude_secondaries && b.category() == Category::Secondary)
511+
|| (exclude_stables && b.category() == Category::Stable);
483512
}
484513
if let Some(exclude_suffixes) = exclude_suffixes.as_mut() {
485-
skip |= substring_matches(exclude_suffixes, |suffix| name.ends_with(suffix));
514+
skip |= substring_matches(exclude_suffixes, |suffix| b.name.0.ends_with(suffix));
486515
}
487516
if skip {
488517
continue;
489518
}
490519

491-
debug!("benchmark `{}`- registered", name);
492-
benchmarks.push(Benchmark::new(name, path)?);
520+
debug!("benchmark `{}`- registered", b.name);
521+
benchmarks.push(b);
493522
}
494523

495524
// All prefixes/suffixes must be used at least once. This is to catch typos.

0 commit comments

Comments
 (0)