Fix compilation of benchmarks

This switches to `SmallRng` since that doesn't require adding another dependency.
This commit is contained in:
Nathan Stoddard 2020-06-03 16:40:02 -07:00 committed by Dzmitry Malyshau
parent 8d0e3f4eae
commit 2c7ee50ef4
6 changed files with 13 additions and 10 deletions

View file

@ -24,7 +24,8 @@ swizzle = []
approx = "0.3" approx = "0.3"
mint = { version = "0.5", optional = true } mint = { version = "0.5", optional = true }
num-traits = "0.2" num-traits = "0.2"
rand = { version = "0.7", optional = true } # small_rng used only for benchmarks
rand = { version = "0.7", features = ["small_rng"], optional = true }
serde = { version = "1.0", features = ["serde_derive"], optional = true } serde = { version = "1.0", features = ["serde_derive"], optional = true }
simd = { version = "0.2", optional = true } # works only in rust toolchain up to 1.32 simd = { version = "0.2", optional = true } # works only in rust toolchain up to 1.32

View file

@ -19,7 +19,7 @@ macro_rules! bench_binop {
fn $name(bh: &mut Bencher) { fn $name(bh: &mut Bencher) {
const LEN: usize = 1 << 13; const LEN: usize = 1 << 13;
let mut rng = IsaacRng::from_entropy(); let mut rng = SmallRng::from_entropy();
let elems1: Vec<$t1> = (0..LEN).map(|_| rng.gen::<$t1>()).collect(); let elems1: Vec<$t1> = (0..LEN).map(|_| rng.gen::<$t1>()).collect();
let elems2: Vec<$t2> = (0..LEN).map(|_| rng.gen::<$t2>()).collect(); let elems2: Vec<$t2> = (0..LEN).map(|_| rng.gen::<$t2>()).collect();
@ -40,7 +40,7 @@ macro_rules! bench_unop {
fn $name(bh: &mut Bencher) { fn $name(bh: &mut Bencher) {
const LEN: usize = 1 << 13; const LEN: usize = 1 << 13;
let mut rng = IsaacRng::from_entropy(); let mut rng = SmallRng::from_entropy();
let mut elems: Vec<$t> = (0..LEN).map(|_| rng.gen::<$t>()).collect(); let mut elems: Vec<$t> = (0..LEN).map(|_| rng.gen::<$t>()).collect();
let mut i = 0; let mut i = 0;
@ -60,7 +60,7 @@ macro_rules! bench_construction {
fn $name(bh: &mut Bencher) { fn $name(bh: &mut Bencher) {
const LEN: usize = 1 << 13; const LEN: usize = 1 << 13;
let mut rng = IsaacRng::from_entropy(); let mut rng = SmallRng::from_entropy();
$(let $args: Vec<$types> = (0..LEN).map(|_| rng.gen::<$types>()).collect();)* $(let $args: Vec<$types> = (0..LEN).map(|_| rng.gen::<$types>()).collect();)*
let mut i = 0; let mut i = 0;

View file

@ -20,10 +20,11 @@ extern crate cgmath;
extern crate rand; extern crate rand;
extern crate test; extern crate test;
use cgmath::*; use rand::{Rng, SeedableRng, rngs::SmallRng};
use rand::{FromEntropy, IsaacRng, Rng};
use test::Bencher; use test::Bencher;
use cgmath::*;
#[path = "common/macros.rs"] #[path = "common/macros.rs"]
#[macro_use] #[macro_use]
mod macros; mod macros;
@ -31,7 +32,7 @@ mod macros;
fn bench_from_axis_angle<T: Rotation3<f32>>(bh: &mut Bencher) { fn bench_from_axis_angle<T: Rotation3<f32>>(bh: &mut Bencher) {
const LEN: usize = 1 << 13; const LEN: usize = 1 << 13;
let mut rng = IsaacRng::from_entropy(); let mut rng = SmallRng::from_entropy();
let axis: Vec<_> = (0..LEN).map(|_| rng.gen::<Vector3<f32>>()).collect(); let axis: Vec<_> = (0..LEN).map(|_| rng.gen::<Vector3<f32>>()).collect();
let angle: Vec<_> = (0..LEN).map(|_| rng.gen::<Rad<f32>>()).collect(); let angle: Vec<_> = (0..LEN).map(|_| rng.gen::<Rad<f32>>()).collect();

View file

@ -20,7 +20,7 @@ extern crate cgmath;
extern crate rand; extern crate rand;
extern crate test; extern crate test;
use rand::{FromEntropy, IsaacRng, Rng}; use rand::{Rng, SeedableRng, rngs::SmallRng};
use std::ops::*; use std::ops::*;
use test::Bencher; use test::Bencher;

View file

@ -14,12 +14,13 @@
// limitations under the License. // limitations under the License.
#![feature(test)] #![feature(test)]
#![allow(unused_macros)]
extern crate cgmath; extern crate cgmath;
extern crate rand; extern crate rand;
extern crate test; extern crate test;
use rand::{FromEntropy, IsaacRng, Rng}; use rand::{Rng, SeedableRng, rngs::SmallRng};
use std::ops::*; use std::ops::*;
use test::Bencher; use test::Bencher;

View file

@ -20,7 +20,7 @@ extern crate cgmath;
extern crate rand; extern crate rand;
extern crate test; extern crate test;
use rand::{FromEntropy, IsaacRng, Rng}; use rand::{Rng, SeedableRng, rngs::SmallRng};
use std::ops::*; use std::ops::*;
use test::Bencher; use test::Bencher;