Skip to content

Commit 6a3d149

Browse files
committed
Move seq benches to new file
1 parent 95e2f95 commit 6a3d149

File tree

2 files changed

+63
-54
lines changed

2 files changed

+63
-54
lines changed

benches/misc.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const RAND_BENCH_N: u64 = 1000;
99
use test::Bencher;
1010

1111
use rand::prelude::*;
12-
use rand::seq::*;
1312

1413
#[bench]
1514
fn misc_gen_bool_const(b: &mut Bencher) {
@@ -109,59 +108,6 @@ sample_binomial!(misc_binomial_100, 100, 0.99);
109108
sample_binomial!(misc_binomial_1000, 1000, 0.01);
110109
sample_binomial!(misc_binomial_1e12, 1000_000_000_000, 0.2);
111110

112-
#[bench]
113-
fn misc_shuffle_100(b: &mut Bencher) {
114-
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
115-
let x : &mut [usize] = &mut [1; 100];
116-
b.iter(|| {
117-
rng.shuffle(x);
118-
x[0]
119-
})
120-
}
121-
122-
#[bench]
123-
fn misc_sample_iter_10_of_100(b: &mut Bencher) {
124-
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
125-
let x : &[usize] = &[1; 100];
126-
b.iter(|| {
127-
sample_iter(&mut rng, x, 10).unwrap_or_else(|e| e)
128-
})
129-
}
130-
131-
#[bench]
132-
fn misc_sample_slice_10_of_100(b: &mut Bencher) {
133-
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
134-
let x : &[usize] = &[1; 100];
135-
b.iter(|| {
136-
sample_slice(&mut rng, x, 10)
137-
})
138-
}
139-
140-
#[bench]
141-
fn misc_sample_slice_ref_10_of_100(b: &mut Bencher) {
142-
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
143-
let x : &[usize] = &[1; 100];
144-
b.iter(|| {
145-
sample_slice_ref(&mut rng, x, 10)
146-
})
147-
}
148-
149-
macro_rules! sample_indices {
150-
($name:ident, $amount:expr, $length:expr) => {
151-
#[bench]
152-
fn $name(b: &mut Bencher) {
153-
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
154-
b.iter(|| {
155-
sample_indices(&mut rng, $length, $amount)
156-
})
157-
}
158-
}
159-
}
160-
161-
sample_indices!(misc_sample_indices_10_of_1k, 10, 1000);
162-
sample_indices!(misc_sample_indices_50_of_1k, 50, 1000);
163-
sample_indices!(misc_sample_indices_100_of_1k, 100, 1000);
164-
165111
#[bench]
166112
fn gen_1k_iter_repeat(b: &mut Bencher) {
167113
use std::iter;

benches/seq.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#![feature(test)]
2+
#![cfg(features = "alloc")]
3+
4+
extern crate test;
5+
extern crate rand;
6+
7+
use test::Bencher;
8+
9+
use rand::prelude::*;
10+
use rand::seq::*;
11+
12+
#[bench]
13+
fn misc_shuffle_100(b: &mut Bencher) {
14+
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
15+
let x : &mut [usize] = &mut [1; 100];
16+
b.iter(|| {
17+
rng.shuffle(x);
18+
x[0]
19+
})
20+
}
21+
22+
#[bench]
23+
fn misc_sample_iter_10_of_100(b: &mut Bencher) {
24+
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
25+
let x : &[usize] = &[1; 100];
26+
b.iter(|| {
27+
sample_iter(&mut rng, x, 10).unwrap_or_else(|e| e)
28+
})
29+
}
30+
31+
#[bench]
32+
fn misc_sample_slice_10_of_100(b: &mut Bencher) {
33+
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
34+
let x : &[usize] = &[1; 100];
35+
b.iter(|| {
36+
sample_slice(&mut rng, x, 10)
37+
})
38+
}
39+
40+
#[bench]
41+
fn misc_sample_slice_ref_10_of_100(b: &mut Bencher) {
42+
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
43+
let x : &[usize] = &[1; 100];
44+
b.iter(|| {
45+
sample_slice_ref(&mut rng, x, 10)
46+
})
47+
}
48+
49+
macro_rules! sample_indices {
50+
($name:ident, $amount:expr, $length:expr) => {
51+
#[bench]
52+
fn $name(b: &mut Bencher) {
53+
let mut rng = SmallRng::from_rng(thread_rng()).unwrap();
54+
b.iter(|| {
55+
sample_indices(&mut rng, $length, $amount)
56+
})
57+
}
58+
}
59+
}
60+
61+
sample_indices!(misc_sample_indices_10_of_1k, 10, 1000);
62+
sample_indices!(misc_sample_indices_50_of_1k, 50, 1000);
63+
sample_indices!(misc_sample_indices_100_of_1k, 100, 1000);

0 commit comments

Comments
 (0)