diff --git a/Cargo.lock b/Cargo.lock index 839e614..819ee02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - [[package]] name = "anes" version = "0.2.0" @@ -411,7 +402,6 @@ dependencies = [ "quickcheck", "rand", "rayon", - "regex", "serde", "serde_derive", "serde_json", @@ -1037,35 +1027,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "regex" -version = "1.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - [[package]] name = "rustc-demangle" version = "0.1.23" diff --git a/Cargo.toml b/Cargo.toml index 9a975c2..4f76cf8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,6 @@ tinytemplate = "1.2" cast = "0.3" num-traits = { version = "0.2", default-features = false, features = ["std"] } oorandom = "11.1" -regex = { version = "1.10", default-features = false, features = ["std"] } # Optional dependencies rayon = { version = "1.10", optional = true } diff --git a/README.md b/README.md index 6a2c885..60cb24a 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Criterion.rs helps you write fast code by detecting and measuring p ## Reason for this fork -[criterion] is [passively-maintained](https://github.com/bheisler/criterion.rs/blob/f1ea31a92ff919a455f36b13c9a45fd74559d0fe/Cargo.toml#L63C27-L63C48) with outdated dependencies. +criterion is [passively-maintained](https://github.com/bheisler/criterion.rs/blob/f1ea31a92ff919a455f36b13c9a45fd74559d0fe/Cargo.toml#L63C27-L63C48) with outdated dependencies. This is fork is updated with: @@ -36,6 +36,7 @@ This is fork is updated with: * builtin [codspeed](https://codspeed.io) feature * `clap` replaced with [`bpaf`](https://github.com/pacak/bpaf) to reduce binary size and compilation time * merged the `criterion-plot` crate into `criterion2` +* remove regex filter support to reduce compilation speed ## Table of Contents diff --git a/justfile b/justfile new file mode 100644 index 0000000..bec3a0b --- /dev/null +++ b/justfile @@ -0,0 +1,7 @@ +#!/usr/bin/env -S just --justfile + +_default: + @just --list -u + +watch command: + cargo watch -x '{{command}}' diff --git a/src/criterion.rs b/src/criterion.rs index aa74387..a8080e6 100644 --- a/src/criterion.rs +++ b/src/criterion.rs @@ -5,8 +5,6 @@ use std::path::{Path, PathBuf}; use std::sync::MutexGuard; use std::time::Duration; -use regex::Regex; - use crate::bencher::Bencher; use crate::benchmark_group::{BenchmarkGroup, BenchmarkId}; use crate::{ @@ -319,21 +317,6 @@ impl Criterion { self } - #[must_use] - /// Filters the benchmarks. Only benchmarks with names that contain the - /// given string will be executed. - /// - /// This overwrites [`Self::with_benchmark_filter`]. - pub fn with_filter>(mut self, filter: S) -> Criterion { - let filter_text = filter.into(); - let filter = Regex::new(&filter_text).unwrap_or_else(|err| { - panic!("Unable to parse '{}' as a regular expression: {}", filter_text, err) - }); - self.filter = BenchmarkFilter::Regex(filter); - - self - } - /// Only run benchmarks specified by the given filter. /// /// This overwrites [`Self::with_filter`]. @@ -441,14 +424,9 @@ 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()) - } else { - let regex = Regex::new(filter).unwrap_or_else(|err| { - panic!("Unable to parse '{}' as a regular expression: {}", filter, err) - }); - BenchmarkFilter::Regex(regex) - } + // if opts.exact { + BenchmarkFilter::Exact(filter.to_owned()) + // } } else { BenchmarkFilter::AcceptAll }; @@ -550,7 +528,6 @@ impl Criterion { pub(crate) fn filter_matches(&self, id: &str) -> bool { match &self.filter { BenchmarkFilter::AcceptAll => true, - BenchmarkFilter::Regex(regex) => regex.is_match(id), BenchmarkFilter::Exact(exact) => id == exact, BenchmarkFilter::RejectAll => false, } diff --git a/src/lib.rs b/src/lib.rs index d45ea8d..2033926 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,8 +27,6 @@ #[cfg(all(feature = "rayon", target_arch = "wasm32"))] compile_error!("Rayon cannot be used when targeting wasi32. Try disabling default features."); -use regex::Regex; - use serde::{Deserialize, Serialize}; // Needs to be declared before other modules @@ -374,8 +372,6 @@ impl Default for ListFormat { pub enum BenchmarkFilter { /// Run all benchmarks. AcceptAll, - /// Run benchmarks matching this regex. - Regex(Regex), /// Run the benchmark matching this string exactly. Exact(String), /// Do not run any benchmarks. diff --git a/tests/criterion_tests.rs b/tests/criterion_tests.rs index eef8526..42b84e5 100644 --- a/tests/criterion_tests.rs +++ b/tests/criterion_tests.rs @@ -1,7 +1,8 @@ #[cfg(feature = "plotters")] use criterion2::SamplingMode; use criterion2::{ - criterion_group, criterion_main, profiler::Profiler, BatchSize, BenchmarkId, Criterion, + criterion_group, criterion_main, profiler::Profiler, BatchSize, BenchmarkFilter, BenchmarkId, + Criterion, }; use serde_json::value::Value; use std::cell::{Cell, RefCell}; @@ -254,7 +255,7 @@ fn test_filtering() { let clone = counter.clone(); short_benchmark(&dir) - .with_filter("Foo") + .with_benchmark_filter(BenchmarkFilter::Exact("Foo".into())) .bench_function("test_filtering", move |b| b.iter(|| clone.count())); assert_eq!(counter.read(), 0);