From 3ae0469743e809be65418e14e27515b5a83ef491 Mon Sep 17 00:00:00 2001 From: pacak Date: Wed, 30 Oct 2024 20:53:45 -0400 Subject: [PATCH] Make filters to look for a substring unless exact is given (#65) eecce42 removed partial filter matches to improve compilation speed, but we can still do something similar without using regex crate by looking for a substring. Plus I'd get regex back and put it behind a feature flag, those who care - can keep using it. --- src/criterion.rs | 10 +++++++--- src/lib.rs | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/criterion.rs b/src/criterion.rs index 5ae2a7c..efc6522 100644 --- a/src/criterion.rs +++ b/src/criterion.rs @@ -379,9 +379,12 @@ impl Criterion { // --ignored overwrites any name-based filters passed in. BenchmarkFilter::RejectAll } else if let Some(filter) = opts.filter.as_ref() { - // if opts.exact { - BenchmarkFilter::Exact(filter.to_owned()) - // } + let filter = filter.to_owned(); + if opts.exact { + BenchmarkFilter::Exact(filter) + } else { + BenchmarkFilter::Substring(filter) + } } else { BenchmarkFilter::AcceptAll }; @@ -475,6 +478,7 @@ impl Criterion { BenchmarkFilter::AcceptAll => true, BenchmarkFilter::Exact(exact) => id == exact, BenchmarkFilter::RejectAll => false, + BenchmarkFilter::Substring(s) => id.contains(s), } } diff --git a/src/lib.rs b/src/lib.rs index ba6822e..ad70278 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -291,6 +291,8 @@ pub enum BenchmarkFilter { AcceptAll, /// Run the benchmark matching this string exactly. Exact(String), + /// Look for benchmark that contain substring + Substring(String), /// Do not run any benchmarks. RejectAll, }