Skip to content

Commit

Permalink
Fix benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Sep 1, 2017
1 parent 1f1db33 commit db93780
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions benches/distributions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rand::distributions::gamma::Gamma;

#[bench]
fn distr_baseline(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();

b.iter(|| {
for _ in 0..::RAND_BENCH_N {
Expand All @@ -32,7 +32,7 @@ fn distr_baseline(b: &mut Bencher) {

#[bench]
fn distr_range_int(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();
let distr = Range::new(3i64, 134217671i64);

b.iter(|| {
Expand All @@ -45,7 +45,7 @@ fn distr_range_int(b: &mut Bencher) {

#[bench]
fn distr_range_float(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();
let distr = Range::new(2.26f64, 2.319f64);

b.iter(|| {
Expand All @@ -59,8 +59,8 @@ fn distr_range_float(b: &mut Bencher) {

#[bench]
fn distr_range2_int(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let distr = range2::range(3i64, 134217671i64);
let mut rng = XorShiftRng::new().unwrap();
let distr = range2::Range::new(3i64, 134217671i64);

b.iter(|| {
for _ in 0..::RAND_BENCH_N {
Expand All @@ -72,8 +72,8 @@ fn distr_range2_int(b: &mut Bencher) {

#[bench]
fn distr_range2_float(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let distr = range2::range(2.26f64, 2.319f64);
let mut rng = XorShiftRng::new().unwrap();
let distr = range2::Range::new(2.26f64, 2.319f64);

b.iter(|| {
for _ in 0..::RAND_BENCH_N {
Expand All @@ -86,7 +86,7 @@ fn distr_range2_float(b: &mut Bencher) {

#[bench]
fn distr_exp(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();
let distr = Exp::new(2.71828 * 3.14159);

b.iter(|| {
Expand All @@ -100,7 +100,7 @@ fn distr_exp(b: &mut Bencher) {

#[bench]
fn distr_normal(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();
let distr = Normal::new(-2.71828, 3.14159);

b.iter(|| {
Expand All @@ -113,7 +113,7 @@ fn distr_normal(b: &mut Bencher) {

#[bench]
fn distr_log_normal(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();
let distr = LogNormal::new(-2.71828, 3.14159);

b.iter(|| {
Expand All @@ -127,7 +127,7 @@ fn distr_log_normal(b: &mut Bencher) {

#[bench]
fn distr_gamma_large_shape(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();
let distr = Gamma::new(10., 1.0);

b.iter(|| {
Expand All @@ -140,7 +140,7 @@ fn distr_gamma_large_shape(b: &mut Bencher) {

#[bench]
fn distr_gamma_small_shape(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();
let distr = Gamma::new(0.1, 1.0);

b.iter(|| {
Expand Down
4 changes: 2 additions & 2 deletions benches/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn misc_convert_f64(b: &mut Bencher) {

#[bench]
fn misc_shuffle_100(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();
let x : &mut [usize] = &mut [1; 100];
b.iter(|| {
x.shuffle(&mut rng);
Expand All @@ -67,7 +67,7 @@ fn misc_shuffle_100(b: &mut Bencher) {

#[bench]
fn misc_sample_10_of_100(b: &mut Bencher) {
let mut rng = XorShiftRng::new();
let mut rng = XorShiftRng::new().unwrap();
let x : &[usize] = &[1; 100];
b.iter(|| {
sample(&mut rng, x, 10);
Expand Down

0 comments on commit db93780

Please sign in to comment.