Major amounts of progress
This commit is contained in:
@@ -71,6 +71,9 @@ impl Random {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::utils::random::Random;
|
||||
extern crate test;
|
||||
use std::hint::black_box;
|
||||
use test::Bencher;
|
||||
|
||||
#[test]
|
||||
fn create_random() {
|
||||
@@ -176,4 +179,14 @@ mod tests {
|
||||
assert_approx_eq::assert_approx_eq!(num_zeros as f32 / num_twos as f32, 1.0, 0.01);
|
||||
assert_approx_eq::assert_approx_eq!(num_ones as f32 / num_twos as f32, 1.0, 0.01);
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn bench_1000_random_ints_between(b: &mut Bencher) {
|
||||
b.iter(|| {
|
||||
let mut random = Random::default();
|
||||
for _ in 0..1000 {
|
||||
black_box(random.get_between(0, 100));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user