diff options
Diffstat (limited to 'vendor/fastrand/benches/bench.rs')
-rw-r--r-- | vendor/fastrand/benches/bench.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/fastrand/benches/bench.rs b/vendor/fastrand/benches/bench.rs index 53826ce5c..4b882b74f 100644 --- a/vendor/fastrand/benches/bench.rs +++ b/vendor/fastrand/benches/bench.rs @@ -73,3 +73,26 @@ fn u32_fastrand(b: &mut Bencher) { sum }) } + +#[bench] +fn fill(b: &mut Bencher) { + let rng = fastrand::Rng::new(); + b.iter(|| { + // Pick a size that isn't divisble by 8. + let mut bytes = [0u8; 367]; + rng.fill(&mut bytes); + bytes + }) +} + +#[bench] +fn fill_naive(b: &mut Bencher) { + let rng = fastrand::Rng::new(); + b.iter(|| { + let mut bytes = [0u8; 367]; + for item in &mut bytes { + *item = rng.u8(..); + } + bytes + }) +} |