aboutsummaryrefslogtreecommitdiff
path: root/rand/benches/distributions/gamma.rs
blob: bf3fd367a9b6c995ba756492fb7fe1c4160a1aad (plain)
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
use std::mem::size_of;
use test::Bencher;
use rand;
use rand::distributions::IndependentSample;
use rand::distributions::gamma::Gamma;

#[bench]
fn bench_gamma_large_shape(b: &mut Bencher) {
    let gamma = Gamma::new(10., 1.0);
    let mut rng = rand::weak_rng();

    b.iter(|| {
        for _ in 0..::RAND_BENCH_N {
            gamma.ind_sample(&mut rng);
        }
    });
    b.bytes = size_of::<f64>() as u64 * ::RAND_BENCH_N;
}

#[bench]
fn bench_gamma_small_shape(b: &mut Bencher) {
    let gamma = Gamma::new(0.1, 1.0);
    let mut rng = rand::weak_rng();

    b.iter(|| {
        for _ in 0..::RAND_BENCH_N {
            gamma.ind_sample(&mut rng);
        }
    });
    b.bytes = size_of::<f64>() as u64 * ::RAND_BENCH_N;
}