Merge pull request #148 from elichai/2019-08-travis

Optimizing travis build time and fixing benchmarks
This commit is contained in:
Tim Ruffing 2019-08-13 17:50:24 +02:00 committed by GitHub
commit dfe7ee54f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 20 deletions

View File

@ -1,5 +1,7 @@
language: rust language: rust
cache: cargo cache:
directories:
- cargo_web
rust: rust:
- stable - stable
@ -10,31 +12,34 @@ os:
- linux - linux
- windows - windows
addons:
chrome: stable
matrix: matrix:
# rand 0.6 actually needs Rust 1.22, which leads to build failures on Rust 1.14 on Windows.
# This is a problem, because
# - we insist on rust 1.22 since #92
# - but "rand" is only an optional dependency.
exclude: exclude:
- rust: 1.22.0 - rust: 1.22.0
os: windows os: windows
script: script:
- cargo build --verbose --no-default-features
- cargo build --verbose --no-default-features --features="serde"
- cargo build --verbose --no-default-features --features="lowmemory"
- cargo build --verbose --no-default-features --features="rand"
- cargo build --verbose --no-default-features --features="rand serde recovery endomorphism"
- cargo build --verbose --no-default-features --features="fuzztarget recovery"
- cargo build --verbose --features=fuzztarget - cargo build --verbose --features=fuzztarget
- cargo build --verbose --features=rand - cargo build --verbose --features=rand
- cargo test --verbose --features=rand - cargo test --verbose --features=rand
- cargo test --verbose --features="rand serde" - cargo test --verbose --features="rand serde"
- cargo test --verbose --features="rand serde recovery endomorphism" - cargo test --verbose --features="rand serde recovery endomorphism"
- cargo build --verbose --no-default-features
- cargo build --verbose --no-default-features --features="serde"
- cargo build --verbose --no-default-features --features="rand"
- cargo build --verbose --no-default-features --features="rand serde recovery endomorphism"
- cargo build --verbose --no-default-features --features="fuzztarget recovery"
- cargo build --verbose --no-default-features --features="lowmemory"
- cargo build --verbose - cargo build --verbose
- cargo test --verbose - cargo test --verbose
- cargo build --release - cargo build --verbose --release
- cargo test --release - cargo test --verbose --release
- cargo bench - if [ ${TRAVIS_RUST_VERSION} == "stable" ]; then cargo doc --verbose --features="rand,serde,recovery,endomorphism"; fi
- if [ "$(rustup show | grep default | grep stable)" != "" ]; then cargo doc; fi - if [ ${TRAVIS_RUST_VERSION} == "nightly" ]; then cargo test --verbose --benches --features=unstable; fi
- if [ "$(rustup show | grep default | grep stable)" != "" -a "$TRAVIS_OS_NAME" = "linux" ]; then cargo install --force cargo-web && cargo web build --target=asmjs-unknown-emscripten && cargo web test --target=asmjs-unknown-emscripten --nodejs; fi - if [ ${TRAVIS_RUST_VERSION} == "stable" -a "$TRAVIS_OS_NAME" = "linux" ]; then
CARGO_TARGET_DIR=cargo_web cargo install --verbose --force cargo-web &&
cargo web build --verbose --target=asmjs-unknown-emscripten &&
cargo web test --verbose --target=asmjs-unknown-emscripten;
fi

View File

@ -999,18 +999,37 @@ mod tests {
#[cfg(all(test, feature = "unstable"))] #[cfg(all(test, feature = "unstable"))]
mod benches { mod benches {
use rand::{Rng, thread_rng}; use rand::{thread_rng, RngCore};
use test::{Bencher, black_box}; use test::{Bencher, black_box};
use super::{Secp256k1, Message}; use super::{Secp256k1, Message};
#[bench] #[bench]
pub fn generate(bh: &mut Bencher) { pub fn generate(bh: &mut Bencher) {
struct CounterRng(u32); struct CounterRng(u64);
impl Rng for CounterRng { impl RngCore for CounterRng {
fn next_u32(&mut self) -> u32 { self.0 += 1; self.0 } fn next_u32(&mut self) -> u32 {
self.next_u64() as u32
} }
fn next_u64(&mut self) -> u64 {
self.0 += 1;
self.0
}
fn fill_bytes(&mut self, dest: &mut [u8]) {
for chunk in dest.chunks_mut(64/8) {
let rand: [u8; 64/8] = unsafe {std::mem::transmute(self.next_u64())};
chunk.copy_from_slice(&rand[..chunk.len()]);
}
}
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
Ok(self.fill_bytes(dest))
}
}
let s = Secp256k1::new(); let s = Secp256k1::new();
let mut r = CounterRng(0); let mut r = CounterRng(0);
bh.iter( || { bh.iter( || {