std::rand: lengthen the RNG benchmarks.

This makes them more representative, as the `bh.iter` is a smaller
percentage of the total time.
This commit is contained in:
Huon Wilson 2013-10-11 22:09:06 +11:00
parent ed5f2d7c7c
commit 83aa1abb19
1 changed files with 20 additions and 8 deletions

View File

@ -970,41 +970,53 @@ mod bench {
use extra::test::BenchHarness;
use rand::*;
use mem::size_of;
use iter::range;
use option::{Some, None};
static N: u64 = 100;
#[bench]
fn rand_xorshift(bh: &mut BenchHarness) {
let mut rng = XorShiftRng::new();
do bh.iter {
rng.gen::<uint>();
for _ in range(0, N) {
rng.gen::<uint>();
}
}
bh.bytes = size_of::<uint>() as u64;
bh.bytes = size_of::<uint>() as u64 * N;
}
#[bench]
fn rand_isaac(bh: &mut BenchHarness) {
let mut rng = IsaacRng::new();
do bh.iter {
rng.gen::<uint>();
for _ in range(0, N) {
rng.gen::<uint>();
}
}
bh.bytes = size_of::<uint>() as u64;
bh.bytes = size_of::<uint>() as u64 * N;
}
#[bench]
fn rand_isaac64(bh: &mut BenchHarness) {
let mut rng = Isaac64Rng::new();
do bh.iter {
rng.gen::<uint>();
for _ in range(0, N) {
rng.gen::<uint>();
}
}
bh.bytes = size_of::<uint>() as u64;
bh.bytes = size_of::<uint>() as u64 * N;
}
#[bench]
fn rand_std(bh: &mut BenchHarness) {
let mut rng = StdRng::new();
do bh.iter {
rng.gen::<uint>();
for _ in range(0, N) {
rng.gen::<uint>();
}
}
bh.bytes = size_of::<uint>() as u64;
bh.bytes = size_of::<uint>() as u64 * N;
}
#[bench]