Skip to content

Commit eabc24c

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

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

collector/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ 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.
127128
- `--exclude-suffix <EXCLUDE>`: this is used to run a subset of the benchmarks. The
128129
argument is a comma-separated list of benchmark suffixes. When this option is
129130
specified, a benchmark is excluded from the run if its name matches one of
@@ -134,7 +135,9 @@ The following options alter the behaviour of the `bench_local` subcommand.
134135
- `--include <INCLUDE>`: the inverse of `--exclude`. The argument is a
135136
comma-separated list of benchmark prefixes. When this option is specified, a
136137
benchmark is included in the run only if its name matches one of the given
137-
prefixes.
138+
prefixes. You can also specify `primary`, `secondary` and `stable` to filter
139+
on the category of benchmarks. `rust-timer` only runs `--include primary,secondary`
140+
on PRs.
138141
- `--profiles <PROFILES>`: the profiles to be benchmarked. The possible choices
139142
are one or more (comma-separated) of `Check`, `Debug`, `Doc`, `Opt`, and
140143
`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: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,28 +468,52 @@ 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

478496
if let Some(includes) = includes.as_mut() {
479-
skip |= !name_matches_prefix(includes);
497+
skip |= !(name_matches_prefix(includes)
498+
|| (include_primaries && b.category() == Category::Primary)
499+
|| (include_secondaries && b.category() == Category::Secondary)
500+
|| (include_stables && b.category() == Category::Stable));
480501
}
481502
if let Some(excludes) = excludes.as_mut() {
482-
skip |= name_matches_prefix(excludes);
503+
skip |= name_matches_prefix(excludes)
504+
|| (exclude_primaries && b.category() == Category::Primary)
505+
|| (exclude_secondaries && b.category() == Category::Secondary)
506+
|| (exclude_stables && b.category() == Category::Stable);
483507
}
484508
if let Some(exclude_suffixes) = exclude_suffixes.as_mut() {
485-
skip |= substring_matches(exclude_suffixes, |suffix| name.ends_with(suffix));
509+
skip |= substring_matches(exclude_suffixes, |suffix| b.name.0.ends_with(suffix));
486510
}
487511
if skip {
488512
continue;
489513
}
490514

491-
debug!("benchmark `{}`- registered", name);
492-
benchmarks.push(Benchmark::new(name, path)?);
515+
debug!("benchmark `{}`- registered", b.name);
516+
benchmarks.push(b);
493517
}
494518

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

0 commit comments

Comments
 (0)