aboutsummaryrefslogtreecommitdiff
path: root/vendor/fastrand/benches
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
committerValentin Popov <valentin@popov.link>2024-07-19 15:37:58 +0300
commita990de90fe41456a23e58bd087d2f107d321f3a1 (patch)
tree15afc392522a9e85dc3332235e311b7d39352ea9 /vendor/fastrand/benches
parent3d48cd3f81164bbfc1a755dc1d4a9a02f98c8ddd (diff)
downloadfparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.tar.xz
fparkan-a990de90fe41456a23e58bd087d2f107d321f3a1.zip
Deleted vendor folder
Diffstat (limited to 'vendor/fastrand/benches')
-rw-r--r--vendor/fastrand/benches/bench.rs98
1 files changed, 0 insertions, 98 deletions
diff --git a/vendor/fastrand/benches/bench.rs b/vendor/fastrand/benches/bench.rs
deleted file mode 100644
index a940aac..0000000
--- a/vendor/fastrand/benches/bench.rs
+++ /dev/null
@@ -1,98 +0,0 @@
-#![feature(test)]
-
-extern crate test;
-
-use rand::prelude::*;
-use test::Bencher;
-use wyhash::WyRng;
-
-#[bench]
-fn shuffle_wyhash(b: &mut Bencher) {
- let mut rng = WyRng::from_rng(thread_rng()).unwrap();
- let mut x = (0..100).collect::<Vec<usize>>();
- b.iter(|| {
- x.shuffle(&mut rng);
- x[0]
- })
-}
-
-#[bench]
-fn shuffle_fastrand(b: &mut Bencher) {
- let mut rng = fastrand::Rng::new();
- let mut x = (0..100).collect::<Vec<usize>>();
- b.iter(|| {
- rng.shuffle(&mut x);
- x[0]
- })
-}
-
-#[bench]
-fn u8_wyhash(b: &mut Bencher) {
- let mut rng = WyRng::from_rng(thread_rng()).unwrap();
- b.iter(|| {
- let mut sum = 0u8;
- for _ in 0..10_000 {
- sum = sum.wrapping_add(rng.gen::<u8>());
- }
- sum
- })
-}
-
-#[bench]
-fn u8_fastrand(b: &mut Bencher) {
- let mut rng = fastrand::Rng::new();
- b.iter(|| {
- let mut sum = 0u8;
- for _ in 0..10_000 {
- sum = sum.wrapping_add(rng.u8(..));
- }
- sum
- })
-}
-
-#[bench]
-fn u32_wyhash(b: &mut Bencher) {
- let mut rng = WyRng::from_rng(thread_rng()).unwrap();
- b.iter(|| {
- let mut sum = 0u32;
- for _ in 0..10_000 {
- sum = sum.wrapping_add(rng.gen::<u32>());
- }
- sum
- })
-}
-
-#[bench]
-fn u32_fastrand(b: &mut Bencher) {
- let mut rng = fastrand::Rng::new();
- b.iter(|| {
- let mut sum = 0u32;
- for _ in 0..10_000 {
- sum = sum.wrapping_add(rng.u32(..));
- }
- sum
- })
-}
-
-#[bench]
-fn fill(b: &mut Bencher) {
- let mut 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 mut rng = fastrand::Rng::new();
- b.iter(|| {
- let mut bytes = [0u8; 367];
- for item in &mut bytes {
- *item = rng.u8(..);
- }
- bytes
- })
-}