Skip to content

Commit

Permalink
Make criterion a benchmarking only dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Feb 1, 2025
1 parent e800aca commit c66a944
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,20 @@ async = []
loom = { version = "0.7.2", features = ["futures"], optional = true }

[dev-dependencies]
criterion = "0.5.1"
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros", "time"] }
async-std = { version = "1", features = ["attributes"] }

# Benchmarking only dependency. This is hidden behind a `cfg(criterion)` to avoid it being
# pulled in during `cargo test` runs. Mostly because criterion has a much higher MSRV than
# this library, so it becomes impossible to run `cargo test` on the MSRV compiler without
# this hack.
# To run benchmarks, run with `RUSTFLAGS="--cfg criterion" cargo bench`
[target.'cfg(criterion)'.dev-dependencies]
criterion = "0.5.1"


[lints.rust]
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(oneshot_loom)', 'cfg(oneshot_test_delay)'] }
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(oneshot_loom)', 'cfg(oneshot_test_delay)', 'cfg(criterion)'] }

[[bench]]
name = "benches"
Expand Down
3 changes: 3 additions & 0 deletions benches/benches.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#[cfg(not(criterion))]
compile_error!("To run benches, you neet to run with RUSTFLAGS=\"--cfg criterion\"");

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use std::mem;

Expand Down

0 comments on commit c66a944

Please sign in to comment.