From 95639c5a274c2467096841a22f282d1fe0b516eb Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 25 Nov 2017 14:48:09 +0000 Subject: [PATCH] Add JitterRng benchmark, and enable CI benchmarking Partly this is just to add an *optimised* test --- .travis.yml | 1 + appveyor.yml | 1 + benches/bench.rs | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1cb2e68cbb8..60211e5bbe0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ matrix: - rust: beta - rust: nightly script: + - cargo bench - cargo test - cargo test --features nightly - cargo test --manifest-path rand-derive/Cargo.toml diff --git a/appveyor.yml b/appveyor.yml index 39c6a180be8..815eb97467c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -32,6 +32,7 @@ install: build: false test_script: + - cargo bench - cargo test - cargo test --features nightly - cargo test --manifest-path rand-derive/Cargo.toml diff --git a/benches/bench.rs b/benches/bench.rs index 5fa92bdbea0..043c12f9de6 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -9,9 +9,18 @@ mod distributions; use std::mem::size_of; use test::{black_box, Bencher}; -use rand::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng}; +use rand::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, JitterRng, Rng}; use rand::{OsRng, sample, weak_rng}; +#[bench] +fn rand_jitter(b: &mut Bencher) { + let mut rng = JitterRng::new().unwrap(); + b.iter(|| { + black_box(rng.next_u64()); + }); + b.bytes = size_of::() as u64; +} + #[bench] fn rand_xorshift(b: &mut Bencher) { let mut rng: XorShiftRng = OsRng::new().unwrap().gen();