Major amounts of progress

This commit is contained in:
2022-06-03 16:35:18 +02:00
parent c194c5d209
commit 310bf857d2
37 changed files with 1558 additions and 29 deletions

View File

@@ -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));
}
});
}
}