nalgebra/benches/vec.rs

60 lines
2.1 KiB
Rust
Raw Permalink Normal View History

2015-02-17 21:10:08 +08:00
#![feature(test)]
extern crate test;
2015-02-17 21:10:08 +08:00
extern crate rand;
extern crate nalgebra as na;
2015-02-17 21:10:08 +08:00
use rand::{IsaacRng, Rng};
use test::Bencher;
2014-11-07 23:15:56 +08:00
use na::{Vec2, Vec3, Vec4};
2015-01-04 05:48:10 +08:00
use std::ops::{Add, Sub, Mul, Div};
2014-11-07 23:15:56 +08:00
#[path="common/macros.rs"]
mod macros;
2014-12-27 18:15:13 +08:00
bench_binop!(_bench_vec2_add_v, Vec2<f32>, Vec2<f32>, add);
bench_binop!(_bench_vec3_add_v, Vec3<f32>, Vec3<f32>, add);
bench_binop!(_bench_vec4_add_v, Vec4<f32>, Vec4<f32>, add);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_binop!(_bench_vec2_sub_v, Vec2<f32>, Vec2<f32>, sub);
bench_binop!(_bench_vec3_sub_v, Vec3<f32>, Vec3<f32>, sub);
bench_binop!(_bench_vec4_sub_v, Vec4<f32>, Vec4<f32>, sub);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_binop!(_bench_vec2_mul_v, Vec2<f32>, Vec2<f32>, mul);
bench_binop!(_bench_vec3_mul_v, Vec3<f32>, Vec3<f32>, mul);
bench_binop!(_bench_vec4_mul_v, Vec4<f32>, Vec4<f32>, mul);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_binop!(_bench_vec2_div_v, Vec2<f32>, Vec2<f32>, div);
bench_binop!(_bench_vec3_div_v, Vec3<f32>, Vec3<f32>, div);
bench_binop!(_bench_vec4_div_v, Vec4<f32>, Vec4<f32>, div);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_binop!(_bench_vec2_add_s, Vec2<f32>, f32, add);
bench_binop!(_bench_vec3_add_s, Vec3<f32>, f32, add);
bench_binop!(_bench_vec4_add_s, Vec4<f32>, f32, add);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_binop!(_bench_vec2_sub_s, Vec2<f32>, f32, sub);
bench_binop!(_bench_vec3_sub_s, Vec3<f32>, f32, sub);
bench_binop!(_bench_vec4_sub_s, Vec4<f32>, f32, sub);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_binop!(_bench_vec2_mul_s, Vec2<f32>, f32, mul);
bench_binop!(_bench_vec3_mul_s, Vec3<f32>, f32, mul);
bench_binop!(_bench_vec4_mul_s, Vec4<f32>, f32, mul);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_binop!(_bench_vec2_div_s, Vec2<f32>, f32, div);
bench_binop!(_bench_vec3_div_s, Vec3<f32>, f32, div);
bench_binop!(_bench_vec4_div_s, Vec4<f32>, f32, div);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_binop_na!(_bench_vec2_dot, Vec2<f32>, Vec2<f32>, dot);
bench_binop_na!(_bench_vec3_dot, Vec3<f32>, Vec3<f32>, dot);
bench_binop_na!(_bench_vec4_dot, Vec4<f32>, Vec4<f32>, dot);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_binop_na!(_bench_vec3_cross, Vec3<f32>, Vec3<f32>, cross);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_unop!(_bench_vec2_norm, Vec2<f32>, norm);
bench_unop!(_bench_vec3_norm, Vec3<f32>, norm);
bench_unop!(_bench_vec4_norm, Vec4<f32>, norm);
2014-11-07 23:15:56 +08:00
2014-12-27 18:15:13 +08:00
bench_unop!(_bench_vec2_normalize, Vec2<f32>, normalize);
bench_unop!(_bench_vec3_normalize, Vec3<f32>, normalize);
bench_unop!(_bench_vec4_normalize, Vec4<f32>, normalize);