bheisler / criterion.rs

Statistics-driven benchmarking library for Rust
Apache License 2.0
4.28k stars 290 forks source link

Benchmarks not running when specifying benchmark name #776

Open TrAyZeN opened 2 months ago

TrAyZeN commented 2 months ago

When specifying benchmark name with cargo bench BENCHNAME benchmarks are not run. It used to work, but I encountered this issue and I can reproduce it on criterion example.

Here is the output of cargo bench my_benchmark on criterion example:

$ cargo bench my_benchmark
    Finished bench [optimized] target(s) in 0.02s
     Running unittests src/lib.rs (target/release/deps/mycrate-85c68243aaad160d)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running benches/my_benchmark.rs (target/release/deps/my_benchmark-8c0cd1cf45dd6231)
Gnuplot not found, using plotters backend

Here are the files to reproduce:

See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dev-dependencies] criterion = "=0.5.1"

[[bench]] name = "my_benchmark" harness = false

- src/lib.rs
```rs
#[inline]
pub fn fibonacci(n: u64) -> u64 {
    match n {
        0 => 1,
        1 => 1,
        n => fibonacci(n - 1) + fibonacci(n - 2),
    }
}

pub fn criterion_benchmark(c: &mut Criterion) { c.bench_function("fib 20", |b| b.iter(|| fibonacci(black_box(20)))); }

criterion_group!(benches, criterion_benchmark); criterion_main!(benches);



Rust version: 1.77.2