Merge rust-bitcoin/rust-secp256k1#473: Create configuration conditional "bench"
a431edb86a
Create configuration conditional bench (Tobin C. Harding)2a1c9ab4b8
Remove rand-std feature from unstable (Tobin C. Harding)ddc108c117
Increase heading size (Tobin C. Harding)596adff8ba
Remove unneeded whitespace (Tobin C. Harding) Pull request description: As we did in rust-bitcoin [0] create a configuration conditional `bench` that we can use to guard bench mark code. This has the benefit of making our features additive i.e., we can now test with `--all-features` with a stable toolchain (currently this fails because of our use of the `test` crate). Please note, this patch maintains the current behaviour of turning on the `recovery` and `rand-std` features when benching although I was unable to ascertain why this is needed. [0] - https://github.com/rust-bitcoin/rust-bitcoin/pull/1092 ACKs for top commit: sanket1729: ACKa431edb86a
. apoelstra: ACKa431edb86a
Tree-SHA512: 913f5fbe0da08ec649081bf237c1d31cee58dacdac251d6030afabb99d455286c6d1dbdb6b2ac892b5d3c24584933254d1cfeec8e12f531cc420bd9d455a6531
This commit is contained in:
commit
71b47d1273
|
@ -18,7 +18,6 @@ features = [ "rand", "rand-std", "serde", "bitcoin_hashes", "recovery", "global-
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
unstable = ["recovery", "rand-std"]
|
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
std = ["alloc", "secp256k1-sys/std"]
|
std = ["alloc", "secp256k1-sys/std"]
|
||||||
# allow use of Secp256k1::new and related API that requires an allocator
|
# allow use of Secp256k1::new and related API that requires an allocator
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[Full documentation](https://docs.rs/secp256k1/)
|
[Full documentation](https://docs.rs/secp256k1/)
|
||||||
|
|
||||||
### rust-secp256k1
|
## rust-secp256k1
|
||||||
|
|
||||||
`rust-secp256k1` is a wrapper around [libsecp256k1](https://github.com/bitcoin-core/secp256k1),
|
`rust-secp256k1` is a wrapper around [libsecp256k1](https://github.com/bitcoin-core/secp256k1),
|
||||||
a C library by Pieter Wuille for producing ECDSA signatures using the SECG curve
|
a C library by Pieter Wuille for producing ECDSA signatures using the SECG curve
|
||||||
|
@ -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.
|
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
|
## Fuzzing
|
||||||
|
|
||||||
If you want to fuzz this library, or any library which depends on it, you will
|
If you want to fuzz this library, or any library which depends on it, you will
|
||||||
|
|
|
@ -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"
|
cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Bench
|
|
||||||
if [ "$DO_BENCH" = true ]; then
|
# Bench if told to, only works with non-stable toolchain (nightly, beta).
|
||||||
cargo bench --all --features="unstable"
|
if [ "$DO_BENCH" = true ]
|
||||||
|
then
|
||||||
|
RUSTFLAGS='--cfg=bench' cargo bench --features=recovery
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -286,7 +286,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(test, feature = "unstable"))]
|
#[cfg(bench)]
|
||||||
mod benches {
|
mod benches {
|
||||||
use test::{Bencher, black_box};
|
use test::{Bencher, black_box};
|
||||||
|
|
||||||
|
|
|
@ -452,8 +452,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(bench)]
|
||||||
#[cfg(all(test, feature = "unstable"))]
|
|
||||||
mod benches {
|
mod benches {
|
||||||
use rand::{thread_rng, RngCore};
|
use rand::{thread_rng, RngCore};
|
||||||
use test::{Bencher, black_box};
|
use test::{Bencher, black_box};
|
||||||
|
|
|
@ -2433,7 +2433,7 @@ mod test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(test, feature = "unstable"))]
|
#[cfg(bench)]
|
||||||
mod benches {
|
mod benches {
|
||||||
use test::Bencher;
|
use test::Bencher;
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
|
@ -155,14 +155,16 @@
|
||||||
#![allow(clippy::missing_safety_doc)]
|
#![allow(clippy::missing_safety_doc)]
|
||||||
|
|
||||||
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
|
#![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(docsrs, feature(doc_cfg))]
|
||||||
|
#![cfg_attr(bench, feature(test))]
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
#[cfg(any(test, feature = "std"))]
|
#[cfg(any(test, feature = "std"))]
|
||||||
extern crate core;
|
extern crate core;
|
||||||
#[cfg(all(test, feature = "unstable"))]
|
#[cfg(bench)]
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -1060,7 +1062,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(test, feature = "unstable"))]
|
#[cfg(bench)]
|
||||||
mod benches {
|
mod benches {
|
||||||
use test::{Bencher, black_box};
|
use test::{Bencher, black_box};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue