Fix benchmarks

This commit is contained in:
Vinzent Steinberg 2018-07-06 10:56:35 +02:00
parent ef41836ec5
commit 0faada0687
3 changed files with 12 additions and 9 deletions

View File

@ -9,14 +9,15 @@ use bencher::Bencher;
/// Create a random vector by sampling from a normal distribution.
fn initialize_vec() -> Vec<f64> {
use rand::distributions::{Normal, IndependentSample};
use rand::distributions::{Normal, Distribution};
use rand::{XorShiftRng, SeedableRng};
let normal = Normal::new(2.0, 3.0);
let n = 1_000_000;
let mut values = Vec::with_capacity(n);
let mut rng = XorShiftRng::from_seed([1, 2, 3, 4]);
let mut rng = XorShiftRng::from_seed(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
for _ in 0..n {
values.push(normal.ind_sample(&mut rng));
values.push(normal.sample(&mut rng));
}
values
}

View File

@ -10,14 +10,15 @@ use bencher::Bencher;
/// Create a random vector by sampling from a normal distribution.
fn initialize_vec() -> Vec<f64> {
use rand::distributions::{Normal, IndependentSample};
use rand::distributions::{Normal, Distribution};
use rand::{XorShiftRng, SeedableRng};
let normal = Normal::new(2.0, 3.0);
let n = 1_000_000;
let mut values = Vec::with_capacity(n);
let mut rng = XorShiftRng::from_seed([1, 2, 3, 4]);
let mut rng = XorShiftRng::from_seed(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
for _ in 0..n {
values.push(normal.ind_sample(&mut rng));
values.push(normal.sample(&mut rng));
}
values
}

View File

@ -10,14 +10,15 @@ use bencher::Bencher;
/// Create a random vector of random floats in [0, 1].
fn initialize_vec() -> Vec<f64> {
use rand::distributions::{Range, IndependentSample};
use rand::distributions::{Range, Distribution};
use rand::{XorShiftRng, SeedableRng};
let range = Range::new(0.0, 1.0);
let n = 1_000_000;
let mut values = Vec::with_capacity(n);
let mut rng = XorShiftRng::from_seed([1, 2, 3, 4]);
let mut rng = XorShiftRng::from_seed(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
for _ in 0..n {
values.push(range.ind_sample(&mut rng));
values.push(range.sample(&mut rng));
}
values
}