1 use std::mem::size_of; 2 use test::Bencher; 3 use rand; 4 use rand::distributions::Sample; 5 use rand::distributions::normal::Normal; 6 7 #[bench] rand_normal(b: &mut Bencher)8fn rand_normal(b: &mut Bencher) { 9 let mut rng = rand::weak_rng(); 10 let mut normal = Normal::new(-2.71828, 3.14159); 11 12 b.iter(|| { 13 for _ in 0..::RAND_BENCH_N { 14 normal.sample(&mut rng); 15 } 16 }); 17 b.bytes = size_of::<f64>() as u64 * ::RAND_BENCH_N; 18 } 19