1 use std::mem::size_of;
2 use test::Bencher;
3 use rand;
4 use rand::distributions::IndependentSample;
5 use rand::distributions::gamma::Gamma;
6 
7 #[bench]
bench_gamma_large_shape(b: &mut Bencher)8 fn bench_gamma_large_shape(b: &mut Bencher) {
9     let gamma = Gamma::new(10., 1.0);
10     let mut rng = rand::weak_rng();
11 
12     b.iter(|| {
13         for _ in 0..::RAND_BENCH_N {
14             gamma.ind_sample(&mut rng);
15         }
16     });
17     b.bytes = size_of::<f64>() as u64 * ::RAND_BENCH_N;
18 }
19 
20 #[bench]
bench_gamma_small_shape(b: &mut Bencher)21 fn bench_gamma_small_shape(b: &mut Bencher) {
22     let gamma = Gamma::new(0.1, 1.0);
23     let mut rng = rand::weak_rng();
24 
25     b.iter(|| {
26         for _ in 0..::RAND_BENCH_N {
27             gamma.ind_sample(&mut rng);
28         }
29     });
30     b.bytes = size_of::<f64>() as u64 * ::RAND_BENCH_N;
31 }
32