diff --git a/benches/vec.rs b/benches/vec.rs index d5ff30c3..2e33fa62 100644 --- a/benches/vec.rs +++ b/benches/vec.rs @@ -1,14 +1,15 @@ #![feature(test)] +#[cfg(feature = "generic_sizes")] +extern crate typenum; + extern crate test; extern crate rand; -extern crate typenum; extern crate nalgebra as na; use rand::{IsaacRng, Rng}; use test::Bencher; -use typenum::{U2, U3, U4}; -use na::{Vec2, Vec3, Vec4, VecN}; +use na::{Vec2, Vec3, Vec4}; use std::ops::{Add, Sub, Mul, Div}; #[path="common/macros.rs"] @@ -17,78 +18,95 @@ mod macros; bench_binop!(_bench_vec2_add_v, Vec2, Vec2, add); bench_binop!(_bench_vec3_add_v, Vec3, Vec3, add); bench_binop!(_bench_vec4_add_v, Vec4, Vec4, add); -bench_binop!(_bench_vecn2_add_v, VecN, VecN, add); -bench_binop!(_bench_vecn3_add_v, VecN, VecN, add); -bench_binop!(_bench_vecn4_add_v, VecN, VecN, add); bench_binop!(_bench_vec2_sub_v, Vec2, Vec2, sub); bench_binop!(_bench_vec3_sub_v, Vec3, Vec3, sub); bench_binop!(_bench_vec4_sub_v, Vec4, Vec4, sub); -bench_binop!(_bench_vecn2_sub_v, VecN, VecN, sub); -bench_binop!(_bench_vecn3_sub_v, VecN, VecN, sub); -bench_binop!(_bench_vecn4_sub_v, VecN, VecN, sub); bench_binop!(_bench_vec2_mul_v, Vec2, Vec2, mul); bench_binop!(_bench_vec3_mul_v, Vec3, Vec3, mul); bench_binop!(_bench_vec4_mul_v, Vec4, Vec4, mul); -bench_binop!(_bench_vecn2_mul_v, VecN, VecN, mul); -bench_binop!(_bench_vecn3_mul_v, VecN, VecN, mul); -bench_binop!(_bench_vecn4_mul_v, VecN, VecN, mul); bench_binop!(_bench_vec2_div_v, Vec2, Vec2, div); bench_binop!(_bench_vec3_div_v, Vec3, Vec3, div); bench_binop!(_bench_vec4_div_v, Vec4, Vec4, div); -bench_binop!(_bench_vecn2_div_v, VecN, VecN, div); -bench_binop!(_bench_vecn3_div_v, VecN, VecN, div); -bench_binop!(_bench_vecn4_div_v, VecN, VecN, div); bench_binop!(_bench_vec2_add_s, Vec2, f32, add); bench_binop!(_bench_vec3_add_s, Vec3, f32, add); bench_binop!(_bench_vec4_add_s, Vec4, f32, add); -bench_binop!(_bench_vecn2_add_s, VecN, f32, add); -bench_binop!(_bench_vecn3_add_s, VecN, f32, add); -bench_binop!(_bench_vecn4_add_s, VecN, f32, add); bench_binop!(_bench_vec2_sub_s, Vec2, f32, sub); bench_binop!(_bench_vec3_sub_s, Vec3, f32, sub); bench_binop!(_bench_vec4_sub_s, Vec4, f32, sub); -bench_binop!(_bench_vecn2_sub_s, VecN, f32, sub); -bench_binop!(_bench_vecn3_sub_s, VecN, f32, sub); -bench_binop!(_bench_vecn4_sub_s, VecN, f32, sub); bench_binop!(_bench_vec2_mul_s, Vec2, f32, mul); bench_binop!(_bench_vec3_mul_s, Vec3, f32, mul); bench_binop!(_bench_vec4_mul_s, Vec4, f32, mul); -bench_binop!(_bench_vecn2_mul_s, VecN, f32, mul); -bench_binop!(_bench_vecn3_mul_s, VecN, f32, mul); -bench_binop!(_bench_vecn4_mul_s, VecN, f32, mul); bench_binop!(_bench_vec2_div_s, Vec2, f32, div); bench_binop!(_bench_vec3_div_s, Vec3, f32, div); bench_binop!(_bench_vec4_div_s, Vec4, f32, div); -bench_binop!(_bench_vecn2_div_s, VecN, f32, div); -bench_binop!(_bench_vecn3_div_s, VecN, f32, div); -bench_binop!(_bench_vecn4_div_s, VecN, f32, div); bench_binop_na!(_bench_vec2_dot, Vec2, Vec2, dot); bench_binop_na!(_bench_vec3_dot, Vec3, Vec3, dot); bench_binop_na!(_bench_vec4_dot, Vec4, Vec4, dot); -bench_binop_na!(_bench_vecn2_dot, VecN, VecN, dot); -bench_binop_na!(_bench_vecn3_dot, VecN, VecN, dot); -bench_binop_na!(_bench_vecn4_dot, VecN, VecN, dot); bench_binop_na!(_bench_vec3_cross, Vec3, Vec3, cross); bench_unop!(_bench_vec2_norm, Vec2, norm); bench_unop!(_bench_vec3_norm, Vec3, norm); bench_unop!(_bench_vec4_norm, Vec4, norm); -bench_unop!(_bench_vecn2_norm, VecN, norm); -bench_unop!(_bench_vecn3_norm, VecN, norm); -bench_unop!(_bench_vecn4_norm, VecN, norm); bench_unop!(_bench_vec2_normalize, Vec2, normalize); bench_unop!(_bench_vec3_normalize, Vec3, normalize); bench_unop!(_bench_vec4_normalize, Vec4, normalize); -bench_unop!(_bench_vecn2_normalize, VecN, normalize); -bench_unop!(_bench_vecn3_normalize, VecN, normalize); -bench_unop!(_bench_vecn4_normalize, VecN, normalize); + +#[cfg(feature = "generic_sizes")] +mod bench_vecn { + use typenum::{U2, U3, U4}; + use na::VecN; + + bench_binop!(_bench_vecn2_add_v, VecN, VecN, add); + bench_binop!(_bench_vecn3_add_v, VecN, VecN, add); + bench_binop!(_bench_vecn4_add_v, VecN, VecN, add); + + bench_binop!(_bench_vecn2_sub_v, VecN, VecN, sub); + bench_binop!(_bench_vecn3_sub_v, VecN, VecN, sub); + bench_binop!(_bench_vecn4_sub_v, VecN, VecN, sub); + + bench_binop!(_bench_vecn2_mul_v, VecN, VecN, mul); + bench_binop!(_bench_vecn3_mul_v, VecN, VecN, mul); + bench_binop!(_bench_vecn4_mul_v, VecN, VecN, mul); + + bench_binop!(_bench_vecn2_div_v, VecN, VecN, div); + bench_binop!(_bench_vecn3_div_v, VecN, VecN, div); + bench_binop!(_bench_vecn4_div_v, VecN, VecN, div); + + bench_binop!(_bench_vecn2_add_s, VecN, f32, add); + bench_binop!(_bench_vecn3_add_s, VecN, f32, add); + bench_binop!(_bench_vecn4_add_s, VecN, f32, add); + + bench_binop!(_bench_vecn2_sub_s, VecN, f32, sub); + bench_binop!(_bench_vecn3_sub_s, VecN, f32, sub); + bench_binop!(_bench_vecn4_sub_s, VecN, f32, sub); + + bench_binop!(_bench_vecn2_mul_s, VecN, f32, mul); + bench_binop!(_bench_vecn3_mul_s, VecN, f32, mul); + bench_binop!(_bench_vecn4_mul_s, VecN, f32, mul); + + bench_binop!(_bench_vecn2_div_s, VecN, f32, div); + bench_binop!(_bench_vecn3_div_s, VecN, f32, div); + bench_binop!(_bench_vecn4_div_s, VecN, f32, div); + + bench_binop_na!(_bench_vecn2_dot, VecN, VecN, dot); + bench_binop_na!(_bench_vecn3_dot, VecN, VecN, dot); + bench_binop_na!(_bench_vecn4_dot, VecN, VecN, dot); + + bench_unop!(_bench_vecn2_norm, VecN, norm); + bench_unop!(_bench_vecn3_norm, VecN, norm); + bench_unop!(_bench_vecn4_norm, VecN, norm); + + bench_unop!(_bench_vecn2_normalize, VecN, normalize); + bench_unop!(_bench_vecn3_normalize, VecN, normalize); + bench_unop!(_bench_vecn4_normalize, VecN, normalize); +}