nalgebra/src/bench/vec.rs
Sébastien Crozet f6c597f102 Update to the last rust-nightly.
Version of rustc: 0.11.0-pre-nightly (faa7ba7 2014-05-31 01:06:40 -0700).

Main changes:
        * `cmp::Ord` -> `cmp::PartialOrd`
        * `cmp::Eq`  ->  `cmp::PartialEq`

Note that `na::PartialOrd` is not the same as `cmp::PartialOrd`
(which lacks a lot of partial ordering operators).
2014-06-01 15:22:11 +02:00

46 lines
840 B
Rust

use std::rand::random;
use test::Bencher;
use na::{Vec2, Vec3, Vec4, Vec5, Vec6};
use na;
macro_rules! bench_dot_vec(
($bh: expr, $t: ty) => {
{
let a: $t = random();
let b: $t = random();
let mut d = 0.0;
$bh.iter(|| {
for _ in range(0, 1000) {
d = d + na::dot(&a, &b);
}
})
}
}
)
#[bench]
fn bench_dot_vec2(bh: &mut Bencher) {
bench_dot_vec!(bh, Vec2<f64>)
}
#[bench]
fn bench_dot_vec3(bh: &mut Bencher) {
bench_dot_vec!(bh, Vec3<f64>)
}
#[bench]
fn bench_dot_vec4(bh: &mut Bencher) {
bench_dot_vec!(bh, Vec4<f64>)
}
#[bench]
fn bench_dot_vec5(bh: &mut Bencher) {
bench_dot_vec!(bh, Vec5<f64>)
}
#[bench]
fn bench_dot_vec6(bh: &mut Bencher) {
bench_dot_vec!(bh, Vec6<f64>)
}