You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, it is possible to specify which benchmark using a filter (i.e. cargo bench -- <filter>). This selects which of bench_function to run.
However, I see no way to prevent setup code from running when the corresponding benchmark is not selected. Suppose I have a set of benchmarks with a very long setup time, e.g. indexing a large dataset that could take a minute or two. I'd like to avoid running the setup code for filtered out benchmarks.
Example
use criterion::{criterion_group, criterion_main,Criterion};structBenchee;implBenchee{pubfnvery_long_setup(name:&str) -> Self{eprint!("init {}...", name);
std::thread::sleep(std::time::Duration::from_secs(30));eprintln!(" done");Benchee}pubfnrun(&self){}}pubfncriterion_benchmark(c:&mutCriterion){let one = Benchee::very_long_setup("one");
c.bench_function("one", |b| b.iter(|| one.run()));let two = Benchee::very_long_setup("two");
c.bench_function("two", |b| b.iter(|| two.run()));}criterion_group!(benches, criterion_benchmark);criterion_main!(benches);
$ cargo bench one…init one... doneone time: [0.0000 ps 0.0000 ps 0.0000 ps] change: [-51.749% -6.0500% +73.757%] (p = 0.86 > 0.05) No change in performance detected.Found 12 outliers among 100 measurements (12.00%) 4 (4.00%) high mild 8 (8.00%) high severeinit two... done ← ⚠️ I'd like to avoid this ⚠️
The text was updated successfully, but these errors were encountered:
Currently, it is possible to specify which benchmark using a filter (i.e.
cargo bench -- <filter>
). This selects which ofbench_function
to run.However, I see no way to prevent setup code from running when the corresponding benchmark is not selected. Suppose I have a set of benchmarks with a very long setup time, e.g. indexing a large dataset that could take a minute or two. I'd like to avoid running the setup code for filtered out benchmarks.
Example
The text was updated successfully, but these errors were encountered: