Skip to content

Commit

Permalink
Add benchmarks for ranges of i8 and i16
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Dicker committed Sep 2, 2017
1 parent db93780 commit 33a1e7f
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions benches/distributions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ fn distr_baseline(b: &mut Bencher) {
b.bytes = size_of::<f64>() as u64 * ::RAND_BENCH_N;
}


#[bench]
fn distr_range_int(b: &mut Bencher) {
let mut rng = XorShiftRng::new().unwrap();
Expand All @@ -56,11 +55,10 @@ fn distr_range_float(b: &mut Bencher) {
b.bytes = size_of::<f64>() 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 {
Expand All @@ -70,6 +68,32 @@ fn distr_range2_int(b: &mut Bencher) {
b.bytes = size_of::<i64>() 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::<i8>() 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::<i8>() as u64 * ::RAND_BENCH_N;
}

#[bench]
fn distr_range2_float(b: &mut Bencher) {
let mut rng = XorShiftRng::new().unwrap();
Expand Down

0 comments on commit 33a1e7f

Please sign in to comment.