aboutsummaryrefslogtreecommitdiff
path: root/getrandom/benches/mod.rs
blob: 07953f135a36a78e52caa9697f8445719e8380fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#![feature(test)]
extern crate getrandom;
extern crate test;

#[bench]
fn bench_64(b: &mut test::Bencher) {
    let mut buf = [0u8; 64];
    b.iter(|| {
        getrandom::getrandom(&mut buf[..]).unwrap();
        test::black_box(&buf);
    });
    b.bytes = buf.len() as u64;
}

#[bench]
fn bench_65536(b: &mut test::Bencher) {
    let mut buf = [0u8; 65536];
    b.iter(|| {
        getrandom::getrandom(&mut buf[..]).unwrap();
        test::black_box(&buf);
    });
    b.bytes = buf.len() as u64;
}