Skip to content

Commit

Permalink
Fix compilation of benchmarks
Browse files Browse the repository at this point in the history
This switches to `SmallRng` since that doesn't require adding another dependency.
  • Loading branch information
nstoddard authored and kvark committed Jun 4, 2020
1 parent 8d0e3f4 commit 2c7ee50
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ swizzle = []
approx = "0.3"
mint = { version = "0.5", optional = true }
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 }
simd = { version = "0.2", optional = true } # works only in rust toolchain up to 1.32

Expand Down
6 changes: 3 additions & 3 deletions benches/common/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ macro_rules! bench_binop {
fn $name(bh: &mut Bencher) {
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 elems2: Vec<$t2> = (0..LEN).map(|_| rng.gen::<$t2>()).collect();
Expand All @@ -40,7 +40,7 @@ macro_rules! bench_unop {
fn $name(bh: &mut Bencher) {
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 i = 0;
Expand All @@ -60,7 +60,7 @@ macro_rules! bench_construction {
fn $name(bh: &mut Bencher) {
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 mut i = 0;
Expand Down
7 changes: 4 additions & 3 deletions benches/construction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ extern crate cgmath;
extern crate rand;
extern crate test;

use cgmath::*;
use rand::{FromEntropy, IsaacRng, Rng};
use rand::{Rng, SeedableRng, rngs::SmallRng};
use test::Bencher;

use cgmath::*;

#[path = "common/macros.rs"]
#[macro_use]
mod macros;

fn bench_from_axis_angle<T: Rotation3<f32>>(bh: &mut Bencher) {
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 angle: Vec<_> = (0..LEN).map(|_| rng.gen::<Rad<f32>>()).collect();
Expand Down
2 changes: 1 addition & 1 deletion benches/mat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern crate cgmath;
extern crate rand;
extern crate test;

use rand::{FromEntropy, IsaacRng, Rng};
use rand::{Rng, SeedableRng, rngs::SmallRng};
use std::ops::*;
use test::Bencher;

Expand Down
3 changes: 2 additions & 1 deletion benches/quat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
// limitations under the License.

#![feature(test)]
#![allow(unused_macros)]

extern crate cgmath;
extern crate rand;
extern crate test;

use rand::{FromEntropy, IsaacRng, Rng};
use rand::{Rng, SeedableRng, rngs::SmallRng};
use std::ops::*;
use test::Bencher;

Expand Down
2 changes: 1 addition & 1 deletion benches/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extern crate cgmath;
extern crate rand;
extern crate test;

use rand::{FromEntropy, IsaacRng, Rng};
use rand::{Rng, SeedableRng, rngs::SmallRng};
use std::ops::*;
use test::Bencher;

Expand Down

0 comments on commit 2c7ee50

Please sign in to comment.