Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation of benchmarks #505

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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