Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Benchmarks not running when specifying benchmark name #776

Open
TrAyZeN opened this issue Apr 26, 2024 · 0 comments
Open

Benchmarks not running when specifying benchmark name #776

TrAyZeN opened this issue Apr 26, 2024 · 0 comments

Comments

@TrAyZeN
Copy link

TrAyZeN commented Apr 26, 2024

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:

  • Cargo.toml
[package]
name = "mycrate"
version = "0.1.0"
edition = "2021"

# 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
#[inline]
pub fn fibonacci(n: u64) -> u64 {
    match n {
        0 => 1,
        1 => 1,
        n => fibonacci(n - 1) + fibonacci(n - 2),
    }
}
  • benches/my_benchmark.rs
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use mycrate::fibonacci;

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant