#![feature(test)] extern crate random; extern crate special; extern crate test; use random::Source; use special::Gamma; use test::{black_box, Bencher}; #[bench] fn digamma(bencher: &mut Bencher) { let x = random::default() .iter::() .take(1000) .map(|x| 20.0 * x - 10.0) .collect::>(); bencher.iter(|| { for &x in &x { black_box(x.digamma()); } }); } #[bench] fn inc_gamma(bencher: &mut Bencher) { let (mut x, mut p) = (random::default(), random::default()); let xp = x .iter::() .zip(p.iter::()) .take(1000) .map(|(x, p)| (100.0 * x, 100.0 * p)) .collect::>(); bencher.iter(|| { for &(x, p) in &xp { black_box(x.inc_gamma(p)); } }); } #[bench] fn trigamma(bencher: &mut Bencher) { let x = random::default().iter().take(1000).collect::>(); bencher.iter(|| { for &x in &x { black_box(x.trigamma()); } }); }