-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrandom.rs
38 lines (32 loc) · 898 Bytes
/
random.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Benchmarks PNRG
#![feature(stdsimd)]
extern crate aobench_lib;
#[macro_use]
extern crate criterion;
use aobench_lib::random;
use aobench_lib::geometry::{f32xN};
use criterion::*;
fn random_scalar(c: &mut Criterion) {
c.bench(
"scalar",
Benchmark::new("random", move |b| {
let mut rng = random::scalar::thread_rng();
b.iter(|| {
black_box(rng.gen());
})
}).throughput(Throughput::Elements(1)),
);
}
fn random_vector(c: &mut Criterion) {
c.bench(
"vector",
Benchmark::new("random", move |b| {
let mut rng = random::vector::thread_rng();
b.iter(|| {
black_box(rng.gen());
})
}).throughput(Throughput::Elements(f32xN::lanes() as u32)),
);
}
criterion_group!(benches, random_scalar, random_vector);
criterion_main!(benches);