From 33a1e7fd7a38a49046a3c811b4f62334af6770c7 Mon Sep 17 00:00:00 2001 From: Paul Dicker Date: Sat, 2 Sep 2017 18:57:00 +0200 Subject: [PATCH] Add benchmarks for ranges of i8 and i16 --- benches/distributions.rs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/benches/distributions.rs b/benches/distributions.rs index cff1e3271f7..4023aa63c90 100644 --- a/benches/distributions.rs +++ b/benches/distributions.rs @@ -29,7 +29,6 @@ fn distr_baseline(b: &mut Bencher) { b.bytes = size_of::() as u64 * ::RAND_BENCH_N; } - #[bench] fn distr_range_int(b: &mut Bencher) { let mut rng = XorShiftRng::new().unwrap(); @@ -56,11 +55,10 @@ fn distr_range_float(b: &mut Bencher) { b.bytes = size_of::() as u64 * ::RAND_BENCH_N; } - #[bench] fn distr_range2_int(b: &mut Bencher) { let mut rng = XorShiftRng::new().unwrap(); - let distr = range2::Range::new(3i64, 134217671i64); + let distr = range2::Range::new(3i64, 134217671i64); // almost 2^27 b.iter(|| { for _ in 0..::RAND_BENCH_N { @@ -70,6 +68,32 @@ fn distr_range2_int(b: &mut Bencher) { b.bytes = size_of::() as u64 * ::RAND_BENCH_N; } +#[bench] +fn distr_range2_i8(b: &mut Bencher) { + let mut rng = XorShiftRng::new().unwrap(); + let distr = range2::Range::new(20i8, 100i8); + + b.iter(|| { + for _ in 0..::RAND_BENCH_N { + distr.sample(&mut rng); + } + }); + b.bytes = size_of::() as u64 * ::RAND_BENCH_N; +} + +#[bench] +fn distr_range2_i16(b: &mut Bencher) { + let mut rng = XorShiftRng::new().unwrap(); + let distr = range2::Range::new(-500i16, 500i16); + + b.iter(|| { + for _ in 0..::RAND_BENCH_N { + distr.sample(&mut rng); + } + }); + b.bytes = size_of::() as u64 * ::RAND_BENCH_N; +} + #[bench] fn distr_range2_float(b: &mut Bencher) { let mut rng = XorShiftRng::new().unwrap();