Skip to content

Commit d42470d

Browse files
committed
use exclude-suffixes to filter benchmarks
1 parent afda0ae commit d42470d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

collector/src/benchmark/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ pub fn get_compile_benchmarks(
371371
benchmark_dir: &Path,
372372
include: Option<&str>,
373373
exclude: Option<&str>,
374+
exclude_suffix: Option<&str>,
374375
) -> anyhow::Result<Vec<Benchmark>> {
375376
let mut benchmarks = Vec::new();
376377

@@ -405,19 +406,23 @@ pub fn get_compile_benchmarks(
405406

406407
let mut includes = to_hashmap(include);
407408
let mut excludes = to_hashmap(exclude);
409+
let mut exclude_suffixes = to_hashmap(exclude_suffix);
408410

409411
for (path, name) in paths {
410412
let mut skip = false;
411413

412-
let name_matches = |prefixes: &mut HashMap<&str, usize>| {
414+
let name_matches_prefix = |prefixes: &mut HashMap<&str, usize>| {
413415
substring_matches(prefixes, |prefix| name.starts_with(prefix))
414416
};
415417

416418
if let Some(includes) = includes.as_mut() {
417-
skip |= !name_matches(includes);
419+
skip |= !name_matches_prefix(includes);
418420
}
419421
if let Some(excludes) = excludes.as_mut() {
420-
skip |= name_matches(excludes);
422+
skip |= name_matches_prefix(excludes);
423+
}
424+
if let Some(exclude_suffixes) = exclude_suffixes.as_mut() {
425+
skip |= substring_matches(exclude_suffixes, |suffix| name.ends_with(suffix));
421426
}
422427
if skip {
423428
continue;

collector/src/bin/collector.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,7 @@ fn main_result() -> anyhow::Result<i32> {
770770
&compile_benchmark_dir,
771771
local.include.as_deref(),
772772
local.exclude.as_deref(),
773+
local.exclude_suffix.as_deref(),
773774
)?;
774775
benchmarks.retain(|b| b.category().is_primary_or_secondary());
775776

@@ -836,6 +837,7 @@ fn main_result() -> anyhow::Result<i32> {
836837
&compile_benchmark_dir,
837838
include.as_deref(),
838839
exclude.as_deref(),
840+
None,
839841
)?;
840842
benchmarks.retain(|b| b.category().is_primary_or_secondary());
841843

@@ -896,6 +898,7 @@ fn main_result() -> anyhow::Result<i32> {
896898
&compile_benchmark_dir,
897899
local.include.as_deref(),
898900
local.exclude.as_deref(),
901+
local.exclude_suffix.as_deref(),
899902
)?;
900903
benchmarks.retain(|b| b.category().is_primary_or_secondary());
901904

@@ -1055,7 +1058,7 @@ fn bench_published_artifact(
10551058
let cargo = which("cargo")?;
10561059

10571060
// Exclude benchmarks that don't work with a stable compiler.
1058-
let mut benchmarks = get_compile_benchmarks(&benchmark_dir, None, None)?;
1061+
let mut benchmarks = get_compile_benchmarks(&benchmark_dir, None, None, None)?;
10591062
benchmarks.retain(|b| b.category().is_stable());
10601063

10611064
let res = bench(

0 commit comments

Comments
 (0)