diff --git a/Cargo.toml b/Cargo.toml index 0a41c55..0de60bc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ features = [ "rand", "rand-std", "serde", "bitcoin_hashes", "recovery", "global- rustdoc-args = ["--cfg", "docsrs"] [features] -unstable = ["recovery"] default = ["std"] std = ["alloc", "secp256k1-sys/std"] # allow use of Secp256k1::new and related API that requires an allocator diff --git a/README.md b/README.md index 22f952c..86d0f80 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,11 @@ git config --local core.hooksPath githooks/ Alternatively add symlinks in your `.git/hooks` directory to any of the githooks we provide. +### Benchmarks + +We use a custom Rust compiler configuration conditional to guard the bench mark code. To run the +bench marks use: `RUSTFLAGS='--cfg=bench' cargo +nightly bench --features=recovery`. + ## Fuzzing If you want to fuzz this library, or any library which depends on it, you will diff --git a/contrib/test.sh b/contrib/test.sh index f4e088e..7933a53 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -98,9 +98,11 @@ if [ "$DO_ASAN" = true ]; then cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully" fi -# Bench -if [ "$DO_BENCH" = true ]; then - cargo bench --all --features="unstable" + +# Bench if told to, only works with non-stable toolchain (nightly, beta). +if [ "$DO_BENCH" = true ] +then + RUSTFLAGS='--cfg=bench' cargo bench --features=recovery fi exit 0 diff --git a/src/ecdh.rs b/src/ecdh.rs index 70ad705..70a5cbf 100644 --- a/src/ecdh.rs +++ b/src/ecdh.rs @@ -286,7 +286,7 @@ mod tests { } } -#[cfg(all(test, feature = "unstable"))] +#[cfg(bench)] mod benches { use test::{Bencher, black_box}; diff --git a/src/ecdsa/recovery.rs b/src/ecdsa/recovery.rs index ce9768f..9b531b0 100644 --- a/src/ecdsa/recovery.rs +++ b/src/ecdsa/recovery.rs @@ -452,7 +452,7 @@ mod tests { } } -#[cfg(all(test, feature = "unstable"))] +#[cfg(bench)] mod benches { use rand::{thread_rng, RngCore}; use test::{Bencher, black_box}; diff --git a/src/key.rs b/src/key.rs index 9971f0c..91ad391 100644 --- a/src/key.rs +++ b/src/key.rs @@ -2433,7 +2433,7 @@ mod test { } } -#[cfg(all(test, feature = "unstable"))] +#[cfg(bench)] mod benches { use test::Bencher; use std::collections::BTreeSet; diff --git a/src/lib.rs b/src/lib.rs index c2dc65f..9e336b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,14 +155,16 @@ #![allow(clippy::missing_safety_doc)] #![cfg_attr(all(not(test), not(feature = "std")), no_std)] -#![cfg_attr(all(test, feature = "unstable"), feature(test))] + +// Experimental features we need. #![cfg_attr(docsrs, feature(doc_cfg))] +#![cfg_attr(bench, feature(test))] #[cfg(feature = "alloc")] extern crate alloc; #[cfg(any(test, feature = "std"))] extern crate core; -#[cfg(all(test, feature = "unstable"))] +#[cfg(bench)] extern crate test; #[macro_use] @@ -1060,7 +1062,7 @@ mod tests { } } -#[cfg(all(test, feature = "unstable"))] +#[cfg(bench)] mod benches { use test::{Bencher, black_box};