diff --git a/tiny-bench/benches/benchmark.rs b/tiny-bench/benches/benchmark.rs index 3d1d23a..709c123 100644 --- a/tiny-bench/benches/benchmark.rs +++ b/tiny-bench/benches/benchmark.rs @@ -1,13 +1,20 @@ +#[cfg(feature = "bench")] use std::time::Duration; +#[cfg(feature = "bench")] use tiny_bench::{black_box, BenchmarkConfig}; fn main() { + #[cfg(feature = "bench")] bench_test_one(); + #[cfg(feature = "bench")] bench_test_two(); + #[cfg(feature = "bench")] bench_test_three(); + #[cfg(feature = "bench")] bench_test_four(); } +#[cfg(feature = "bench")] fn bench_test_one() { tiny_bench::bench_labeled("test one", || { let mut v: Vec = Vec::with_capacity(10_000); @@ -22,6 +29,7 @@ fn bench_test_one() { }); } +#[cfg(feature = "bench")] fn bench_test_two() { tiny_bench::bench_with_setup_labeled( "test two", @@ -43,10 +51,12 @@ fn bench_test_two() { ); } +#[cfg(feature = "bench")] fn bench_test_three() { tiny_bench::bench_labeled("test three, empty", || {}); } +#[cfg(feature = "bench")] fn bench_test_four() { tiny_bench::bench_with_configuration_labeled( "test four, max_it", diff --git a/tiny-bench/src/output/analysis/criterion/mod.rs b/tiny-bench/src/output/analysis/criterion/mod.rs index 46b7c83..32f9775 100644 --- a/tiny-bench/src/output/analysis/criterion/mod.rs +++ b/tiny-bench/src/output/analysis/criterion/mod.rs @@ -18,6 +18,7 @@ use std::time::Duration; /// } /// ``` #[allow(unsafe_code)] +#[allow(clippy::mem_forget)] pub fn black_box(dummy: T) -> T { unsafe { let ret = std::ptr::read_volatile(&dummy);