Port all remaining benchmarks to criterion.
This commit is contained in:
parent
dabff333e7
commit
1e60bc822b
|
@ -1,7 +1,6 @@
|
|||
use na::{DMatrix, DVector, Matrix2, Matrix3, Matrix4, MatrixN, Vector2, Vector3, Vector4, U10};
|
||||
use rand::{IsaacRng, Rng};
|
||||
use std::ops::{Add, Div, Mul, Sub};
|
||||
use test::{self, Bencher};
|
||||
|
||||
#[path = "../common/macros.rs"]
|
||||
mod macros;
|
||||
|
@ -46,155 +45,196 @@ bench_unop!(mat2_transpose, Matrix2<f32>, transpose);
|
|||
bench_unop!(mat3_transpose, Matrix3<f32>, transpose);
|
||||
bench_unop!(mat4_transpose, Matrix4<f32>, transpose);
|
||||
|
||||
#[bench]
|
||||
fn mat_div_scalar(b: &mut Bencher) {
|
||||
fn mat_div_scalar(b: &mut criterion::Criterion) {
|
||||
let a = DMatrix::from_row_slice(1000, 1000, &vec![2.0; 1000000]);
|
||||
let n = 42.0;
|
||||
|
||||
b.iter(|| {
|
||||
b.bench_function("mat_div_scalar", move |bh| bh.iter(|| {
|
||||
let mut aa = a.clone();
|
||||
let mut b = aa.slice_mut((0, 0), (1000, 1000));
|
||||
b /= n
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat100_add_mat100(bench: &mut Bencher) {
|
||||
fn mat100_add_mat100(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(100, 100);
|
||||
let b = DMatrix::<f64>::new_random(100, 100);
|
||||
|
||||
bench.iter(|| &a + &b)
|
||||
bench.bench_function("mat100_add_mat100", move |bh| bh.iter(|| &a + &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat4_mul_mat4(bench: &mut Bencher) {
|
||||
fn mat4_mul_mat4(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(4, 4);
|
||||
let b = DMatrix::<f64>::new_random(4, 4);
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat4_mul_mat4", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat5_mul_mat5(bench: &mut Bencher) {
|
||||
fn mat5_mul_mat5(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(5, 5);
|
||||
let b = DMatrix::<f64>::new_random(5, 5);
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat5_mul_mat5", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat6_mul_mat6(bench: &mut Bencher) {
|
||||
fn mat6_mul_mat6(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(6, 6);
|
||||
let b = DMatrix::<f64>::new_random(6, 6);
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat6_mul_mat6", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat7_mul_mat7(bench: &mut Bencher) {
|
||||
fn mat7_mul_mat7(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(7, 7);
|
||||
let b = DMatrix::<f64>::new_random(7, 7);
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat7_mul_mat7", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat8_mul_mat8(bench: &mut Bencher) {
|
||||
fn mat8_mul_mat8(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(8, 8);
|
||||
let b = DMatrix::<f64>::new_random(8, 8);
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat8_mul_mat8", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat9_mul_mat9(bench: &mut Bencher) {
|
||||
fn mat9_mul_mat9(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(9, 9);
|
||||
let b = DMatrix::<f64>::new_random(9, 9);
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat9_mul_mat9", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat10_mul_mat10(bench: &mut Bencher) {
|
||||
fn mat10_mul_mat10(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(10, 10);
|
||||
let b = DMatrix::<f64>::new_random(10, 10);
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat10_mul_mat10", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat10_mul_mat10_static(bench: &mut Bencher) {
|
||||
fn mat10_mul_mat10_static(bench: &mut criterion::Criterion) {
|
||||
let a = MatrixN::<f64, U10>::new_random();
|
||||
let b = MatrixN::<f64, U10>::new_random();
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat10_mul_mat10_static", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat100_mul_mat100(bench: &mut Bencher) {
|
||||
fn mat100_mul_mat100(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(100, 100);
|
||||
let b = DMatrix::<f64>::new_random(100, 100);
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat100_mul_mat100", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat500_mul_mat500(bench: &mut Bencher) {
|
||||
fn mat500_mul_mat500(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::from_element(500, 500, 5f64);
|
||||
let b = DMatrix::<f64>::from_element(500, 500, 6f64);
|
||||
|
||||
bench.iter(|| &a * &b)
|
||||
bench.bench_function("mat500_mul_mat500", move |bh| bh.iter(|| &a * &b));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn copy_from(bench: &mut Bencher) {
|
||||
fn copy_from(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(1000, 1000);
|
||||
let mut b = DMatrix::<f64>::new_random(1000, 1000);
|
||||
|
||||
bench.iter(|| {
|
||||
bench.bench_function("copy_from", move |bh| bh.iter(|| {
|
||||
b.copy_from(&a);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn axpy(bench: &mut Bencher) {
|
||||
fn axpy(bench: &mut criterion::Criterion) {
|
||||
let x = DVector::<f64>::from_element(100000, 2.0);
|
||||
let mut y = DVector::<f64>::from_element(100000, 3.0);
|
||||
let a = 42.0;
|
||||
|
||||
bench.iter(|| {
|
||||
bench.bench_function("axpy", move |bh| bh.iter(|| {
|
||||
y.axpy(a, &x, 1.0);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn tr_mul_to(bench: &mut Bencher) {
|
||||
fn tr_mul_to(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(1000, 1000);
|
||||
let b = DVector::<f64>::new_random(1000);
|
||||
let mut c = DVector::from_element(1000, 0.0);
|
||||
|
||||
bench.iter(|| a.tr_mul_to(&b, &mut c))
|
||||
bench.bench_function("", move |bh| bh.iter(|| a.tr_mul_to(&b, &mut c)));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat_mul_mat(bench: &mut Bencher) {
|
||||
fn mat_mul_mat(bench: &mut criterion::Criterion) {
|
||||
let a = DMatrix::<f64>::new_random(100, 100);
|
||||
let b = DMatrix::<f64>::new_random(100, 100);
|
||||
let mut ab = DMatrix::<f64>::from_element(100, 100, 0.0);
|
||||
|
||||
bench.iter(|| {
|
||||
bench.bench_function("mat_mul_mat", move |bh| bh.iter(|| {
|
||||
test::black_box(a.mul_to(&b, &mut ab));
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat100_from_fn(bench: &mut Bencher) {
|
||||
bench.iter(|| DMatrix::from_fn(100, 100, |a, b| a + b))
|
||||
fn mat100_from_fn(bench: &mut criterion::Criterion) {
|
||||
bench.bench_function("mat100_from_fn", move |bh| bh.iter(|| DMatrix::from_fn(100, 100, |a, b| a + b)));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn mat500_from_fn(bench: &mut Bencher) {
|
||||
bench.iter(|| DMatrix::from_fn(500, 500, |a, b| a + b))
|
||||
fn mat500_from_fn(bench: &mut criterion::Criterion) {
|
||||
bench.bench_function("mat500_from_fn", move |bh| bh.iter(|| DMatrix::from_fn(500, 500, |a, b| a + b)));
|
||||
}
|
||||
|
||||
criterion_group!(matrix, mat2_transpose);
|
||||
criterion_group!(matrix,
|
||||
mat2_mul_m,
|
||||
mat3_mul_m,
|
||||
mat4_mul_m,
|
||||
|
||||
mat2_tr_mul_m,
|
||||
mat3_tr_mul_m,
|
||||
mat4_tr_mul_m,
|
||||
|
||||
mat2_add_m,
|
||||
mat3_add_m,
|
||||
mat4_add_m,
|
||||
|
||||
mat2_sub_m,
|
||||
mat3_sub_m,
|
||||
mat4_sub_m,
|
||||
|
||||
mat2_mul_v,
|
||||
mat3_mul_v,
|
||||
mat4_mul_v,
|
||||
|
||||
mat2_tr_mul_v,
|
||||
mat3_tr_mul_v,
|
||||
mat4_tr_mul_v,
|
||||
|
||||
mat2_mul_s,
|
||||
mat3_mul_s,
|
||||
mat4_mul_s,
|
||||
|
||||
mat2_div_s,
|
||||
mat3_div_s,
|
||||
mat4_div_s,
|
||||
|
||||
mat2_inv,
|
||||
mat3_inv,
|
||||
mat4_inv,
|
||||
|
||||
mat2_transpose,
|
||||
mat3_transpose,
|
||||
mat4_transpose,
|
||||
|
||||
mat_div_scalar,
|
||||
mat100_add_mat100,
|
||||
mat4_mul_mat4,
|
||||
mat5_mul_mat5,
|
||||
mat6_mul_mat6,
|
||||
mat7_mul_mat7,
|
||||
mat8_mul_mat8,
|
||||
mat9_mul_mat9,
|
||||
mat10_mul_mat10,
|
||||
mat10_mul_mat10_static,
|
||||
mat100_mul_mat100,
|
||||
mat500_mul_mat500,
|
||||
copy_from,
|
||||
axpy,
|
||||
tr_mul_to,
|
||||
mat_mul_mat,
|
||||
mat100_from_fn,
|
||||
mat500_from_fn,
|
||||
);
|
|
@ -1,2 +1,5 @@
|
|||
pub mod matrix;
|
||||
pub mod vector;
|
||||
pub use self::matrix::matrix;
|
||||
pub use self::vector::vector;
|
||||
|
||||
mod matrix;
|
||||
mod vector;
|
||||
|
|
|
@ -54,7 +54,7 @@ fn vec10000_axpy_f64(bh: &mut criterion::Criterion) {
|
|||
let b = DVector::new_random(10000);
|
||||
let n = rng.gen::<f64>();
|
||||
|
||||
bh.bench_function("", move |bh| bh.iter(|| a.axpy(n, &b, 1.0)));
|
||||
bh.bench_function("vec10000_axpy_f64", move |bh| bh.iter(|| a.axpy(n, &b, 1.0)));
|
||||
}
|
||||
|
||||
fn vec10000_axpy_beta_f64(bh: &mut criterion::Criterion) {
|
||||
|
@ -65,7 +65,7 @@ fn vec10000_axpy_beta_f64(bh: &mut criterion::Criterion) {
|
|||
let n = rng.gen::<f64>();
|
||||
let beta = rng.gen::<f64>();
|
||||
|
||||
bh.bench_function("", move |bh| bh.iter(|| a.axpy(n, &b, beta)));
|
||||
bh.bench_function("vec10000_axpy_beta_f64", move |bh| bh.iter(|| a.axpy(n, &b, beta)));
|
||||
}
|
||||
|
||||
fn vec10000_axpy_f64_slice(bh: &mut criterion::Criterion) {
|
||||
|
@ -75,7 +75,7 @@ fn vec10000_axpy_f64_slice(bh: &mut criterion::Criterion) {
|
|||
let b = DVector::new_random(10000);
|
||||
let n = rng.gen::<f64>();
|
||||
|
||||
bh.bench_function("", move |bh| bh.iter(|| {
|
||||
bh.bench_function("vec10000_axpy_f64_slice", move |bh| bh.iter(|| {
|
||||
let mut a = a.fixed_rows_mut::<U10000>(0);
|
||||
let b = b.fixed_rows::<U10000>(0);
|
||||
|
||||
|
@ -91,7 +91,7 @@ fn vec10000_axpy_f64_static(bh: &mut criterion::Criterion) {
|
|||
let n = rng.gen::<f64>();
|
||||
|
||||
// NOTE: for some reasons, it is much faster if the arument are boxed (Box::new(VectorN...)).
|
||||
bh.bench_function("", move |bh| bh.iter(|| a.axpy(n, &b, 1.0)));
|
||||
bh.bench_function("vec10000_axpy_f64_static", move |bh| bh.iter(|| a.axpy(n, &b, 1.0)));
|
||||
}
|
||||
|
||||
fn vec10000_axpy_f32(bh: &mut criterion::Criterion) {
|
||||
|
@ -101,7 +101,7 @@ fn vec10000_axpy_f32(bh: &mut criterion::Criterion) {
|
|||
let b = DVector::new_random(10000);
|
||||
let n = rng.gen::<f32>();
|
||||
|
||||
bh.bench_function("", move |bh| bh.iter(|| a.axpy(n, &b, 1.0)));
|
||||
bh.bench_function("vec10000_axpy_f32", move |bh| bh.iter(|| a.axpy(n, &b, 1.0)));
|
||||
}
|
||||
|
||||
fn vec10000_axpy_beta_f32(bh: &mut criterion::Criterion) {
|
||||
|
@ -112,7 +112,55 @@ fn vec10000_axpy_beta_f32(bh: &mut criterion::Criterion) {
|
|||
let n = rng.gen::<f32>();
|
||||
let beta = rng.gen::<f32>();
|
||||
|
||||
bh.bench_function("", move |bh| bh.iter(|| a.axpy(n, &b, beta)));
|
||||
bh.bench_function("vec10000_axpy_beta_f32", move |bh| bh.iter(|| a.axpy(n, &b, beta)));
|
||||
}
|
||||
|
||||
criterion_group!(vector, vec10000_axpy_f64_static);
|
||||
criterion_group!(vector,
|
||||
vec2_add_v_f32,
|
||||
vec3_add_v_f32,
|
||||
vec4_add_v_f32,
|
||||
|
||||
vec2_add_v_f64,
|
||||
vec3_add_v_f64,
|
||||
vec4_add_v_f64,
|
||||
|
||||
vec2_sub_v,
|
||||
vec3_sub_v,
|
||||
vec4_sub_v,
|
||||
|
||||
vec2_mul_s,
|
||||
vec3_mul_s,
|
||||
vec4_mul_s,
|
||||
|
||||
vec2_div_s,
|
||||
vec3_div_s,
|
||||
vec4_div_s,
|
||||
|
||||
vec2_dot_f32,
|
||||
vec3_dot_f32,
|
||||
vec4_dot_f32,
|
||||
|
||||
vec2_dot_f64,
|
||||
vec3_dot_f64,
|
||||
vec4_dot_f64,
|
||||
|
||||
vec3_cross,
|
||||
|
||||
vec2_norm,
|
||||
vec3_norm,
|
||||
vec4_norm,
|
||||
|
||||
vec2_normalize,
|
||||
vec3_normalize,
|
||||
vec4_normalize,
|
||||
|
||||
vec10000_dot_f64,
|
||||
vec10000_dot_f32,
|
||||
|
||||
vec10000_axpy_f64,
|
||||
vec10000_axpy_beta_f64,
|
||||
vec10000_axpy_f64_slice,
|
||||
vec10000_axpy_f64_static,
|
||||
vec10000_axpy_f32,
|
||||
vec10000_axpy_beta_f32
|
||||
);
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
pub use quaternion::quaternion;
|
||||
|
||||
mod quaternion;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use na::{Quaternion, UnitQuaternion, Vector3};
|
||||
use rand::{IsaacRng, Rng};
|
||||
use std::ops::{Add, Div, Mul, Sub};
|
||||
use test::{self, Bencher};
|
||||
|
||||
#[path = "../common/macros.rs"]
|
||||
mod macros;
|
||||
|
@ -25,3 +24,14 @@ bench_unop!(unit_quaternion_inv, UnitQuaternion<f32>, inverse);
|
|||
|
||||
// bench_unop_self!(quaternion_conjugate, Quaternion<f32>, conjugate);
|
||||
// bench_unop!(quaternion_normalize, Quaternion<f32>, normalize);
|
||||
|
||||
criterion_group!(quaternion,
|
||||
quaternion_add_q,
|
||||
quaternion_sub_q,
|
||||
quaternion_mul_q,
|
||||
unit_quaternion_mul_v,
|
||||
quaternion_mul_s,
|
||||
quaternion_div_s,
|
||||
quaternion_inv,
|
||||
unit_quaternion_inv
|
||||
);
|
|
@ -22,4 +22,18 @@ fn reproductible_dmatrix(nrows: usize, ncols: usize) -> DMatrix<f64> {
|
|||
DMatrix::<f64>::from_fn(nrows, ncols, |_, _| rng.gen())
|
||||
}
|
||||
|
||||
criterion_main!(core::matrix::matrix, core::vector::vector, linalg::bidiagonal);
|
||||
criterion_main!(
|
||||
core::matrix,
|
||||
core::vector,
|
||||
geometry::quaternion,
|
||||
linalg::bidiagonal,
|
||||
linalg::cholesky,
|
||||
linalg::full_piv_lu,
|
||||
linalg::hessenberg,
|
||||
linalg::lu,
|
||||
linalg::qr,
|
||||
linalg::schur,
|
||||
linalg::solve,
|
||||
linalg::svd,
|
||||
linalg::symmetric_eigen,
|
||||
);
|
|
@ -67,9 +67,9 @@ criterion_group!(bidiagonal,
|
|||
bidiagonalize_100x500,
|
||||
bidiagonalize_4x4,
|
||||
bidiagonalize_500x100,
|
||||
bidiagonalize_500x500,
|
||||
// bidiagonalize_500x500, // too long
|
||||
bidiagonalize_unpack_100x100,
|
||||
bidiagonalize_unpack_100x500,
|
||||
bidiagonalize_unpack_500x100,
|
||||
bidiagonalize_unpack_500x500
|
||||
// bidiagonalize_unpack_500x500 // too long
|
||||
);
|
|
@ -1,109 +1,112 @@
|
|||
use na::{Cholesky, DMatrix, DVector};
|
||||
use test::{self, Bencher};
|
||||
|
||||
#[bench]
|
||||
fn cholesky_100x100(bh: &mut Bencher) {
|
||||
fn cholesky_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let m = &m * m.transpose();
|
||||
|
||||
bh.iter(|| test::black_box(Cholesky::new(m.clone())))
|
||||
bh.bench_function("cholesky_100x100", move |bh| bh.iter(|| test::black_box(Cholesky::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn cholesky_500x500(bh: &mut Bencher) {
|
||||
fn cholesky_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let m = &m * m.transpose();
|
||||
|
||||
bh.iter(|| test::black_box(Cholesky::new(m.clone())))
|
||||
bh.bench_function("cholesky_500x500", move |bh| bh.iter(|| test::black_box(Cholesky::new(m.clone()))));
|
||||
}
|
||||
|
||||
// With unpack.
|
||||
#[bench]
|
||||
fn cholesky_decompose_unpack_100x100(bh: &mut Bencher) {
|
||||
fn cholesky_decompose_unpack_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let m = &m * m.transpose();
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("cholesky_decompose_unpack_100x100", move |bh| bh.iter(|| {
|
||||
let chol = Cholesky::new(m.clone()).unwrap();
|
||||
let _ = chol.unpack();
|
||||
})
|
||||
}));
|
||||
}
|
||||
#[bench]
|
||||
fn cholesky_decompose_unpack_500x500(bh: &mut Bencher) {
|
||||
fn cholesky_decompose_unpack_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let m = &m * m.transpose();
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("cholesky_decompose_unpack_500x500", move |bh| bh.iter(|| {
|
||||
let chol = Cholesky::new(m.clone()).unwrap();
|
||||
let _ = chol.unpack();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn cholesky_solve_10x10(bh: &mut Bencher) {
|
||||
fn cholesky_solve_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let m = &m * m.transpose();
|
||||
let v = DVector::<f64>::new_random(10);
|
||||
let chol = Cholesky::new(m.clone()).unwrap();
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("cholesky_solve_10x10", move |bh| bh.iter(|| {
|
||||
let _ = chol.solve(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn cholesky_solve_100x100(bh: &mut Bencher) {
|
||||
fn cholesky_solve_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let m = &m * m.transpose();
|
||||
let v = DVector::<f64>::new_random(100);
|
||||
let chol = Cholesky::new(m.clone()).unwrap();
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("cholesky_solve_100x100", move |bh| bh.iter(|| {
|
||||
let _ = chol.solve(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn cholesky_solve_500x500(bh: &mut Bencher) {
|
||||
fn cholesky_solve_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let m = &m * m.transpose();
|
||||
let v = DVector::<f64>::new_random(500);
|
||||
let chol = Cholesky::new(m.clone()).unwrap();
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("cholesky_solve_500x500", move |bh| bh.iter(|| {
|
||||
let _ = chol.solve(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn cholesky_inverse_10x10(bh: &mut Bencher) {
|
||||
|
||||
fn cholesky_inverse_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let m = &m * m.transpose();
|
||||
let chol = Cholesky::new(m.clone()).unwrap();
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("cholesky_inverse_10x10", move |bh| bh.iter(|| {
|
||||
let _ = chol.inverse();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn cholesky_inverse_100x100(bh: &mut Bencher) {
|
||||
fn cholesky_inverse_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let m = &m * m.transpose();
|
||||
let chol = Cholesky::new(m.clone()).unwrap();
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("cholesky_inverse_100x100", move |bh| bh.iter(|| {
|
||||
let _ = chol.inverse();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn cholesky_inverse_500x500(bh: &mut Bencher) {
|
||||
fn cholesky_inverse_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let m = &m * m.transpose();
|
||||
let chol = Cholesky::new(m.clone()).unwrap();
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("cholesky_inverse_500x500", move |bh| bh.iter(|| {
|
||||
let _ = chol.inverse();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
criterion_group!(cholesky,
|
||||
cholesky_100x100,
|
||||
cholesky_500x500,
|
||||
cholesky_decompose_unpack_100x100,
|
||||
cholesky_decompose_unpack_500x500,
|
||||
cholesky_solve_10x10,
|
||||
cholesky_solve_100x100,
|
||||
cholesky_solve_500x500,
|
||||
cholesky_inverse_10x10,
|
||||
cholesky_inverse_100x100,
|
||||
cholesky_inverse_500x500
|
||||
);
|
|
@ -1,30 +1,33 @@
|
|||
use test::Bencher;
|
||||
use na::{DMatrix, Eigen};
|
||||
|
||||
#[bench]
|
||||
fn eigen_100x100(bh: &mut Bencher) {
|
||||
fn eigen_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
|
||||
bh.iter(|| Eigen::new(m.clone(), 1.0e-7, 0))
|
||||
bh.bench_function("eigen_100x100", move |bh| bh.iter(|| Eigen::new(m.clone(), 1.0e-7, 0)));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn eigen_500x500(bh: &mut Bencher) {
|
||||
fn eigen_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
|
||||
bh.iter(|| Eigen::new(m.clone(), 1.0e-7, 0))
|
||||
bh.bench_function("eigen_500x500", move |bh| bh.iter(|| Eigen::new(m.clone(), 1.0e-7, 0)));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn eigenvalues_100x100(bh: &mut Bencher) {
|
||||
fn eigenvalues_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
|
||||
bh.iter(|| m.clone().eigenvalues(1.0e-7, 0))
|
||||
bh.bench_function("eigenvalues_100x100", move |bh| bh.iter(|| m.clone().eigenvalues(1.0e-7, 0)));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn eigenvalues_500x500(bh: &mut Bencher) {
|
||||
fn eigenvalues_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
|
||||
bh.iter(|| m.clone().eigenvalues(1.0e-7, 0))
|
||||
bh.bench_function("eigenvalues_500x500", move |bh| bh.iter(|| m.clone().eigenvalues(1.0e-7, 0)));
|
||||
}
|
||||
|
||||
criterion_group!(eigen,
|
||||
eigen_100x100,
|
||||
// eigen_500x500,
|
||||
eigenvalues_100x100,
|
||||
// eigenvalues_500x500
|
||||
);
|
||||
|
|
|
@ -1,102 +1,105 @@
|
|||
use na::{DMatrix, DVector, FullPivLU};
|
||||
use test::{self, Bencher};
|
||||
|
||||
// Without unpack.
|
||||
#[bench]
|
||||
fn full_piv_lu_decompose_10x10(bh: &mut Bencher) {
|
||||
fn full_piv_lu_decompose_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
bh.iter(|| test::black_box(FullPivLU::new(m.clone())))
|
||||
bh.bench_function("full_piv_lu_decompose_10x10", move |bh| bh.iter(|| test::black_box(FullPivLU::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_decompose_100x100(bh: &mut Bencher) {
|
||||
fn full_piv_lu_decompose_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
bh.iter(|| test::black_box(FullPivLU::new(m.clone())))
|
||||
bh.bench_function("full_piv_lu_decompose_100x100", move |bh| bh.iter(|| test::black_box(FullPivLU::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_decompose_500x500(bh: &mut Bencher) {
|
||||
fn full_piv_lu_decompose_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
bh.iter(|| test::black_box(FullPivLU::new(m.clone())))
|
||||
bh.bench_function("full_piv_lu_decompose_500x500", move |bh| bh.iter(|| test::black_box(FullPivLU::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_solve_10x10(bh: &mut Bencher) {
|
||||
fn full_piv_lu_solve_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let lu = FullPivLU::new(m.clone());
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("full_piv_lu_solve_10x10", move |bh| bh.iter(|| {
|
||||
let mut b = DVector::<f64>::from_element(10, 1.0);
|
||||
lu.solve(&mut b);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_solve_100x100(bh: &mut Bencher) {
|
||||
fn full_piv_lu_solve_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let lu = FullPivLU::new(m.clone());
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("full_piv_lu_solve_100x100", move |bh| bh.iter(|| {
|
||||
let mut b = DVector::<f64>::from_element(100, 1.0);
|
||||
lu.solve(&mut b);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_solve_500x500(bh: &mut Bencher) {
|
||||
fn full_piv_lu_solve_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let lu = FullPivLU::new(m.clone());
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("full_piv_lu_solve_500x500", move |bh| bh.iter(|| {
|
||||
let mut b = DVector::<f64>::from_element(500, 1.0);
|
||||
lu.solve(&mut b);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_inverse_10x10(bh: &mut Bencher) {
|
||||
fn full_piv_lu_inverse_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let lu = FullPivLU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.try_inverse()))
|
||||
bh.bench_function("full_piv_lu_inverse_10x10", move |bh| bh.iter(|| test::black_box(lu.try_inverse())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_inverse_100x100(bh: &mut Bencher) {
|
||||
fn full_piv_lu_inverse_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let lu = FullPivLU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.try_inverse()))
|
||||
bh.bench_function("full_piv_lu_inverse_100x100", move |bh| bh.iter(|| test::black_box(lu.try_inverse())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_inverse_500x500(bh: &mut Bencher) {
|
||||
fn full_piv_lu_inverse_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let lu = FullPivLU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.try_inverse()))
|
||||
bh.bench_function("full_piv_lu_inverse_500x500", move |bh| bh.iter(|| test::black_box(lu.try_inverse())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_determinant_10x10(bh: &mut Bencher) {
|
||||
fn full_piv_lu_determinant_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let lu = FullPivLU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.determinant()))
|
||||
bh.bench_function("full_piv_lu_determinant_10x10", move |bh| bh.iter(|| test::black_box(lu.determinant())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_determinant_100x100(bh: &mut Bencher) {
|
||||
|
||||
fn full_piv_lu_determinant_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let lu = FullPivLU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.determinant()))
|
||||
bh.bench_function("full_piv_lu_determinant_100x100", move |bh| bh.iter(|| test::black_box(lu.determinant())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn full_piv_lu_determinant_500x500(bh: &mut Bencher) {
|
||||
fn full_piv_lu_determinant_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let lu = FullPivLU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.determinant()))
|
||||
bh.bench_function("full_piv_lu_determinant_500x500", move |bh| bh.iter(|| test::black_box(lu.determinant())));
|
||||
}
|
||||
|
||||
criterion_group!(full_piv_lu,
|
||||
full_piv_lu_decompose_10x10,
|
||||
full_piv_lu_decompose_100x100,
|
||||
// full_piv_lu_decompose_500x500,
|
||||
full_piv_lu_solve_10x10,
|
||||
full_piv_lu_solve_100x100,
|
||||
// full_piv_lu_solve_500x500,
|
||||
full_piv_lu_inverse_10x10,
|
||||
full_piv_lu_inverse_100x100,
|
||||
// full_piv_lu_inverse_500x500,
|
||||
full_piv_lu_determinant_10x10,
|
||||
full_piv_lu_determinant_100x100,
|
||||
// full_piv_lu_determinant_500x500
|
||||
);
|
|
@ -1,58 +1,60 @@
|
|||
use na::{DMatrix, Hessenberg, Matrix4};
|
||||
use test::{self, Bencher};
|
||||
|
||||
#[path = "../common/macros.rs"]
|
||||
mod macros;
|
||||
|
||||
// Without unpack.
|
||||
#[bench]
|
||||
fn hessenberg_decompose_4x4(bh: &mut Bencher) {
|
||||
fn hessenberg_decompose_4x4(bh: &mut criterion::Criterion) {
|
||||
let m = Matrix4::<f64>::new_random();
|
||||
bh.iter(|| test::black_box(Hessenberg::new(m.clone())))
|
||||
bh.bench_function("hessenberg_decompose_4x4", move |bh| bh.iter(|| test::black_box(Hessenberg::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn hessenberg_decompose_100x100(bh: &mut Bencher) {
|
||||
fn hessenberg_decompose_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
bh.iter(|| test::black_box(Hessenberg::new(m.clone())))
|
||||
bh.bench_function("hessenberg_decompose_100x100", move |bh| bh.iter(|| test::black_box(Hessenberg::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn hessenberg_decompose_200x200(bh: &mut Bencher) {
|
||||
fn hessenberg_decompose_200x200(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(200, 200);
|
||||
bh.iter(|| test::black_box(Hessenberg::new(m.clone())))
|
||||
bh.bench_function("hessenberg_decompose_200x200", move |bh| bh.iter(|| test::black_box(Hessenberg::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn hessenberg_decompose_500x500(bh: &mut Bencher) {
|
||||
fn hessenberg_decompose_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
bh.iter(|| test::black_box(Hessenberg::new(m.clone())))
|
||||
bh.bench_function("hessenberg_decompose_500x500", move |bh| bh.iter(|| test::black_box(Hessenberg::new(m.clone()))));
|
||||
}
|
||||
|
||||
// With unpack.
|
||||
#[bench]
|
||||
fn hessenberg_decompose_unpack_100x100(bh: &mut Bencher) {
|
||||
fn hessenberg_decompose_unpack_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
bh.iter(|| {
|
||||
bh.bench_function("hessenberg_decompose_unpack_100x100", move |bh| bh.iter(|| {
|
||||
let hess = Hessenberg::new(m.clone());
|
||||
let _ = hess.unpack();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn hessenberg_decompose_unpack_200x200(bh: &mut Bencher) {
|
||||
fn hessenberg_decompose_unpack_200x200(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(200, 200);
|
||||
bh.iter(|| {
|
||||
bh.bench_function("hessenberg_decompose_unpack_200x200", move |bh| bh.iter(|| {
|
||||
let hess = Hessenberg::new(m.clone());
|
||||
let _ = hess.unpack();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn hessenberg_decompose_unpack_500x500(bh: &mut Bencher) {
|
||||
fn hessenberg_decompose_unpack_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
bh.iter(|| {
|
||||
bh.bench_function("hessenberg_decompose_unpack_500x500", move |bh| bh.iter(|| {
|
||||
let hess = Hessenberg::new(m.clone());
|
||||
let _ = hess.unpack();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
criterion_group!(hessenberg,
|
||||
hessenberg_decompose_4x4,
|
||||
hessenberg_decompose_100x100,
|
||||
hessenberg_decompose_200x200,
|
||||
// hessenberg_decompose_500x500,
|
||||
hessenberg_decompose_unpack_100x100,
|
||||
hessenberg_decompose_unpack_200x200,
|
||||
// hessenberg_decompose_unpack_500x500
|
||||
);
|
|
@ -1,102 +1,102 @@
|
|||
use na::{DMatrix, DVector, LU};
|
||||
use test::{self, Bencher};
|
||||
|
||||
// Without unpack.
|
||||
#[bench]
|
||||
fn lu_decompose_10x10(bh: &mut Bencher) {
|
||||
fn lu_decompose_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
bh.iter(|| test::black_box(LU::new(m.clone())))
|
||||
bh.bench_function("lu_decompose_10x10", move |bh| bh.iter(|| test::black_box(LU::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_decompose_100x100(bh: &mut Bencher) {
|
||||
fn lu_decompose_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
bh.iter(|| test::black_box(LU::new(m.clone())))
|
||||
bh.bench_function("lu_decompose_100x100", move |bh| bh.iter(|| test::black_box(LU::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_decompose_500x500(bh: &mut Bencher) {
|
||||
fn lu_decompose_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
bh.iter(|| test::black_box(LU::new(m.clone())))
|
||||
bh.bench_function("lu_decompose_500x500", move |bh| bh.iter(|| test::black_box(LU::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_solve_10x10(bh: &mut Bencher) {
|
||||
fn lu_solve_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let lu = LU::new(m.clone());
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("lu_solve_10x10", move |bh| bh.iter(|| {
|
||||
let mut b = DVector::<f64>::from_element(10, 1.0);
|
||||
lu.solve(&mut b);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_solve_100x100(bh: &mut Bencher) {
|
||||
fn lu_solve_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let lu = LU::new(m.clone());
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("lu_solve_100x100", move |bh| bh.iter(|| {
|
||||
let mut b = DVector::<f64>::from_element(100, 1.0);
|
||||
lu.solve(&mut b);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_solve_500x500(bh: &mut Bencher) {
|
||||
fn lu_solve_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let lu = LU::new(m.clone());
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("", move |bh| bh.iter(|| {
|
||||
let mut b = DVector::<f64>::from_element(500, 1.0);
|
||||
lu.solve(&mut b);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_inverse_10x10(bh: &mut Bencher) {
|
||||
fn lu_inverse_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let lu = LU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.try_inverse()))
|
||||
bh.bench_function("lu_inverse_10x10", move |bh| bh.iter(|| test::black_box(lu.try_inverse())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_inverse_100x100(bh: &mut Bencher) {
|
||||
fn lu_inverse_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let lu = LU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.try_inverse()))
|
||||
bh.bench_function("lu_inverse_100x100", move |bh| bh.iter(|| test::black_box(lu.try_inverse())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_inverse_500x500(bh: &mut Bencher) {
|
||||
fn lu_inverse_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let lu = LU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.try_inverse()))
|
||||
bh.bench_function("lu_inverse_500x500", move |bh| bh.iter(|| test::black_box(lu.try_inverse())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_determinant_10x10(bh: &mut Bencher) {
|
||||
fn lu_determinant_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let lu = LU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.determinant()))
|
||||
bh.bench_function("lu_determinant_10x10", move |bh| bh.iter(|| test::black_box(lu.determinant())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_determinant_100x100(bh: &mut Bencher) {
|
||||
fn lu_determinant_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let lu = LU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.determinant()))
|
||||
bh.bench_function("lu_determinant_100x100", move |bh| bh.iter(|| test::black_box(lu.determinant())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn lu_determinant_500x500(bh: &mut Bencher) {
|
||||
fn lu_determinant_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let lu = LU::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(lu.determinant()))
|
||||
bh.bench_function("", move |bh| bh.iter(|| test::black_box(lu.determinant())));
|
||||
}
|
||||
|
||||
criterion_group!(lu,
|
||||
lu_decompose_10x10,
|
||||
lu_decompose_100x100,
|
||||
// lu_decompose_500x500,
|
||||
lu_solve_10x10,
|
||||
lu_solve_100x100,
|
||||
lu_inverse_10x10,
|
||||
lu_inverse_100x100,
|
||||
// lu_inverse_500x500,
|
||||
lu_determinant_10x10,
|
||||
lu_determinant_100x100
|
||||
);
|
|
@ -1,4 +1,13 @@
|
|||
pub use self::bidiagonal::bidiagonal;
|
||||
pub use self::cholesky::cholesky;
|
||||
pub use self::full_piv_lu::full_piv_lu;
|
||||
pub use self::hessenberg::hessenberg;
|
||||
pub use self::lu::lu;
|
||||
pub use self::qr::qr;
|
||||
pub use self::schur::schur;
|
||||
pub use self::solve::solve;
|
||||
pub use self::svd::svd;
|
||||
pub use self::symmetric_eigen::symmetric_eigen;
|
||||
|
||||
mod bidiagonal;
|
||||
mod cholesky;
|
||||
|
|
|
@ -1,130 +1,133 @@
|
|||
use na::{DMatrix, DVector, Matrix4, QR};
|
||||
use test::{self, Bencher};
|
||||
|
||||
#[path = "../common/macros.rs"]
|
||||
mod macros;
|
||||
|
||||
// Without unpack.
|
||||
#[bench]
|
||||
fn qr_decompose_100x100(bh: &mut Bencher) {
|
||||
fn qr_decompose_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
bh.iter(|| test::black_box(QR::new(m.clone())))
|
||||
bh.bench_function("qr_decompose_100x100", move |bh| bh.iter(|| test::black_box(QR::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_decompose_100x500(bh: &mut Bencher) {
|
||||
fn qr_decompose_100x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 500);
|
||||
bh.iter(|| test::black_box(QR::new(m.clone())))
|
||||
bh.bench_function("qr_decompose_100x500", move |bh| bh.iter(|| test::black_box(QR::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_decompose_4x4(bh: &mut Bencher) {
|
||||
fn qr_decompose_4x4(bh: &mut criterion::Criterion) {
|
||||
let m = Matrix4::<f64>::new_random();
|
||||
bh.iter(|| test::black_box(QR::new(m.clone())))
|
||||
bh.bench_function("qr_decompose_4x4", move |bh| bh.iter(|| test::black_box(QR::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_decompose_500x100(bh: &mut Bencher) {
|
||||
fn qr_decompose_500x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 100);
|
||||
bh.iter(|| test::black_box(QR::new(m.clone())))
|
||||
bh.bench_function("qr_decompose_500x100", move |bh| bh.iter(|| test::black_box(QR::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_decompose_500x500(bh: &mut Bencher) {
|
||||
fn qr_decompose_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
bh.iter(|| test::black_box(QR::new(m.clone())))
|
||||
bh.bench_function("qr_decompose_500x500", move |bh| bh.iter(|| test::black_box(QR::new(m.clone()))));
|
||||
}
|
||||
|
||||
// With unpack.
|
||||
#[bench]
|
||||
fn qr_decompose_unpack_100x100(bh: &mut Bencher) {
|
||||
fn qr_decompose_unpack_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
bh.iter(|| {
|
||||
bh.bench_function("qr_decompose_unpack_100x100", move |bh| bh.iter(|| {
|
||||
let qr = QR::new(m.clone());
|
||||
let _ = qr.unpack();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_decompose_unpack_100x500(bh: &mut Bencher) {
|
||||
fn qr_decompose_unpack_100x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 500);
|
||||
bh.iter(|| {
|
||||
bh.bench_function("qr_decompose_unpack_100x500", move |bh| bh.iter(|| {
|
||||
let qr = QR::new(m.clone());
|
||||
let _ = qr.unpack();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_decompose_unpack_500x100(bh: &mut Bencher) {
|
||||
fn qr_decompose_unpack_500x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 100);
|
||||
bh.iter(|| {
|
||||
bh.bench_function("qr_decompose_unpack_500x100", move |bh| bh.iter(|| {
|
||||
let qr = QR::new(m.clone());
|
||||
let _ = qr.unpack();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_decompose_unpack_500x500(bh: &mut Bencher) {
|
||||
fn qr_decompose_unpack_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
bh.iter(|| {
|
||||
bh.bench_function("qr_decompose_unpack_500x500", move |bh| bh.iter(|| {
|
||||
let qr = QR::new(m.clone());
|
||||
let _ = qr.unpack();
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_solve_10x10(bh: &mut Bencher) {
|
||||
fn qr_solve_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let qr = QR::new(m.clone());
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("qr_solve_10x10", move |bh| bh.iter(|| {
|
||||
let mut b = DVector::<f64>::from_element(10, 1.0);
|
||||
qr.solve(&mut b);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_solve_100x100(bh: &mut Bencher) {
|
||||
fn qr_solve_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let qr = QR::new(m.clone());
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("qr_solve_100x100", move |bh| bh.iter(|| {
|
||||
let mut b = DVector::<f64>::from_element(100, 1.0);
|
||||
qr.solve(&mut b);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_solve_500x500(bh: &mut Bencher) {
|
||||
fn qr_solve_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let qr = QR::new(m.clone());
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("qr_solve_500x500", move |bh| bh.iter(|| {
|
||||
let mut b = DVector::<f64>::from_element(500, 1.0);
|
||||
qr.solve(&mut b);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_inverse_10x10(bh: &mut Bencher) {
|
||||
fn qr_inverse_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(10, 10);
|
||||
let qr = QR::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(qr.try_inverse()))
|
||||
bh.bench_function("qr_inverse_10x10", move |bh| bh.iter(|| test::black_box(qr.try_inverse())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_inverse_100x100(bh: &mut Bencher) {
|
||||
fn qr_inverse_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let qr = QR::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(qr.try_inverse()))
|
||||
bh.bench_function("qr_inverse_100x100", move |bh| bh.iter(|| test::black_box(qr.try_inverse())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn qr_inverse_500x500(bh: &mut Bencher) {
|
||||
fn qr_inverse_500x500(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(500, 500);
|
||||
let qr = QR::new(m.clone());
|
||||
|
||||
bh.iter(|| test::black_box(qr.try_inverse()))
|
||||
bh.bench_function("qr_inverse_500x500", move |bh| bh.iter(|| test::black_box(qr.try_inverse())));
|
||||
}
|
||||
|
||||
|
||||
criterion_group!(qr,
|
||||
qr_decompose_100x100,
|
||||
qr_decompose_100x500,
|
||||
qr_decompose_4x4,
|
||||
qr_decompose_500x100,
|
||||
// qr_decompose_500x500,
|
||||
qr_decompose_unpack_100x100,
|
||||
qr_decompose_unpack_100x500,
|
||||
qr_decompose_unpack_500x100,
|
||||
// qr_decompose_unpack_500x500,
|
||||
qr_solve_10x10,
|
||||
qr_solve_100x100,
|
||||
// qr_solve_500x500,
|
||||
qr_inverse_10x10,
|
||||
qr_inverse_100x100,
|
||||
// qr_inverse_500x500
|
||||
);
|
|
@ -1,50 +1,52 @@
|
|||
use na::{Matrix4, Schur};
|
||||
use test::{self, Bencher};
|
||||
|
||||
#[bench]
|
||||
fn schur_decompose_4x4(bh: &mut Bencher) {
|
||||
fn schur_decompose_4x4(bh: &mut criterion::Criterion) {
|
||||
let m = Matrix4::<f64>::new_random();
|
||||
bh.iter(|| test::black_box(Schur::new(m.clone())))
|
||||
bh.bench_function("schur_decompose_4x4", move |bh| bh.iter(|| test::black_box(Schur::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn schur_decompose_10x10(bh: &mut Bencher) {
|
||||
fn schur_decompose_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(10, 10);
|
||||
bh.iter(|| test::black_box(Schur::new(m.clone())))
|
||||
bh.bench_function("schur_decompose_10x10", move |bh| bh.iter(|| test::black_box(Schur::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn schur_decompose_100x100(bh: &mut Bencher) {
|
||||
fn schur_decompose_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(100, 100);
|
||||
bh.iter(|| test::black_box(Schur::new(m.clone())))
|
||||
bh.bench_function("schur_decompose_100x100", move |bh| bh.iter(|| test::black_box(Schur::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn schur_decompose_200x200(bh: &mut Bencher) {
|
||||
fn schur_decompose_200x200(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(200, 200);
|
||||
bh.iter(|| test::black_box(Schur::new(m.clone())))
|
||||
bh.bench_function("schur_decompose_200x200", move |bh| bh.iter(|| test::black_box(Schur::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn eigenvalues_4x4(bh: &mut Bencher) {
|
||||
fn eigenvalues_4x4(bh: &mut criterion::Criterion) {
|
||||
let m = Matrix4::<f64>::new_random();
|
||||
bh.iter(|| test::black_box(m.complex_eigenvalues()))
|
||||
bh.bench_function("eigenvalues_4x4", move |bh| bh.iter(|| test::black_box(m.complex_eigenvalues())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn eigenvalues_10x10(bh: &mut Bencher) {
|
||||
fn eigenvalues_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(10, 10);
|
||||
bh.iter(|| test::black_box(m.complex_eigenvalues()))
|
||||
bh.bench_function("eigenvalues_10x10", move |bh| bh.iter(|| test::black_box(m.complex_eigenvalues())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn eigenvalues_100x100(bh: &mut Bencher) {
|
||||
fn eigenvalues_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(100, 100);
|
||||
bh.iter(|| test::black_box(m.complex_eigenvalues()))
|
||||
bh.bench_function("eigenvalues_100x100", move |bh| bh.iter(|| test::black_box(m.complex_eigenvalues())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn eigenvalues_200x200(bh: &mut Bencher) {
|
||||
fn eigenvalues_200x200(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(200, 200);
|
||||
bh.iter(|| test::black_box(m.complex_eigenvalues()))
|
||||
bh.bench_function("eigenvalues_200x200", move |bh| bh.iter(|| test::black_box(m.complex_eigenvalues())));
|
||||
}
|
||||
|
||||
criterion_group!(schur,
|
||||
schur_decompose_4x4,
|
||||
schur_decompose_10x10,
|
||||
schur_decompose_100x100,
|
||||
schur_decompose_200x200,
|
||||
eigenvalues_4x4,
|
||||
eigenvalues_10x10,
|
||||
eigenvalues_100x100,
|
||||
eigenvalues_200x200
|
||||
);
|
|
@ -1,82 +1,85 @@
|
|||
use na::{DMatrix, DVector};
|
||||
use test::Bencher;
|
||||
|
||||
#[bench]
|
||||
fn solve_l_triangular_100x100(bh: &mut Bencher) {
|
||||
fn solve_l_triangular_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let v = DVector::<f64>::new_random(100);
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("solve_l_triangular_100x100", move |bh| bh.iter(|| {
|
||||
let _ = m.solve_lower_triangular(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn solve_l_triangular_1000x1000(bh: &mut Bencher) {
|
||||
fn solve_l_triangular_1000x1000(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(1000, 1000);
|
||||
let v = DVector::<f64>::new_random(1000);
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("solve_l_triangular_1000x1000", move |bh| bh.iter(|| {
|
||||
let _ = m.solve_lower_triangular(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn tr_solve_l_triangular_100x100(bh: &mut Bencher) {
|
||||
fn tr_solve_l_triangular_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let v = DVector::<f64>::new_random(100);
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("tr_solve_l_triangular_100x100", move |bh| bh.iter(|| {
|
||||
let _ = m.tr_solve_lower_triangular(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn tr_solve_l_triangular_1000x1000(bh: &mut Bencher) {
|
||||
fn tr_solve_l_triangular_1000x1000(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(1000, 1000);
|
||||
let v = DVector::<f64>::new_random(1000);
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("tr_solve_l_triangular_1000x1000", move |bh| bh.iter(|| {
|
||||
let _ = m.tr_solve_lower_triangular(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn solve_u_triangular_100x100(bh: &mut Bencher) {
|
||||
fn solve_u_triangular_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let v = DVector::<f64>::new_random(100);
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("solve_u_triangular_100x100", move |bh| bh.iter(|| {
|
||||
let _ = m.solve_upper_triangular(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn solve_u_triangular_1000x1000(bh: &mut Bencher) {
|
||||
fn solve_u_triangular_1000x1000(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(1000, 1000);
|
||||
let v = DVector::<f64>::new_random(1000);
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("solve_u_triangular_1000x1000", move |bh| bh.iter(|| {
|
||||
let _ = m.solve_upper_triangular(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn tr_solve_u_triangular_100x100(bh: &mut Bencher) {
|
||||
fn tr_solve_u_triangular_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(100, 100);
|
||||
let v = DVector::<f64>::new_random(100);
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("tr_solve_u_triangular_100x100", move |bh| bh.iter(|| {
|
||||
let _ = m.tr_solve_upper_triangular(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn tr_solve_u_triangular_1000x1000(bh: &mut Bencher) {
|
||||
fn tr_solve_u_triangular_1000x1000(bh: &mut criterion::Criterion) {
|
||||
let m = DMatrix::<f64>::new_random(1000, 1000);
|
||||
let v = DVector::<f64>::new_random(1000);
|
||||
|
||||
bh.iter(|| {
|
||||
bh.bench_function("tr_solve_u_triangular_1000x1000", move |bh| bh.iter(|| {
|
||||
let _ = m.tr_solve_upper_triangular(&v);
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
criterion_group!(solve,
|
||||
solve_l_triangular_100x100,
|
||||
solve_l_triangular_1000x1000,
|
||||
tr_solve_l_triangular_100x100,
|
||||
tr_solve_l_triangular_1000x1000,
|
||||
solve_u_triangular_100x100,
|
||||
solve_u_triangular_1000x1000,
|
||||
tr_solve_u_triangular_100x100,
|
||||
tr_solve_u_triangular_1000x1000
|
||||
);
|
|
@ -1,98 +1,101 @@
|
|||
use na::{Matrix4, SVD};
|
||||
use test::{self, Bencher};
|
||||
|
||||
#[bench]
|
||||
fn svd_decompose_4x4(bh: &mut Bencher) {
|
||||
fn svd_decompose_4x4(bh: &mut criterion::Criterion) {
|
||||
let m = Matrix4::<f64>::new_random();
|
||||
bh.iter(|| test::black_box(SVD::new(m.clone(), true, true)))
|
||||
bh.bench_function("svd_decompose_4x4", move |bh| bh.iter(|| test::black_box(SVD::new(m.clone(), true, true))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn svd_decompose_10x10(bh: &mut Bencher) {
|
||||
fn svd_decompose_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(10, 10);
|
||||
bh.iter(|| test::black_box(SVD::new(m.clone(), true, true)))
|
||||
bh.bench_function("svd_decompose_10x10", move |bh| bh.iter(|| test::black_box(SVD::new(m.clone(), true, true))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn svd_decompose_100x100(bh: &mut Bencher) {
|
||||
fn svd_decompose_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(100, 100);
|
||||
bh.iter(|| test::black_box(SVD::new(m.clone(), true, true)))
|
||||
bh.bench_function("svd_decompose_100x100", move |bh| bh.iter(|| test::black_box(SVD::new(m.clone(), true, true))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn svd_decompose_200x200(bh: &mut Bencher) {
|
||||
fn svd_decompose_200x200(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(200, 200);
|
||||
bh.iter(|| test::black_box(SVD::new(m.clone(), true, true)))
|
||||
bh.bench_function("svd_decompose_200x200", move |bh| bh.iter(|| test::black_box(SVD::new(m.clone(), true, true))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn rank_4x4(bh: &mut Bencher) {
|
||||
fn rank_4x4(bh: &mut criterion::Criterion) {
|
||||
let m = Matrix4::<f64>::new_random();
|
||||
bh.iter(|| test::black_box(m.rank(1.0e-10)))
|
||||
bh.bench_function("rank_4x4", move |bh| bh.iter(|| test::black_box(m.rank(1.0e-10))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn rank_10x10(bh: &mut Bencher) {
|
||||
fn rank_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(10, 10);
|
||||
bh.iter(|| test::black_box(m.rank(1.0e-10)))
|
||||
bh.bench_function("rank_10x10", move |bh| bh.iter(|| test::black_box(m.rank(1.0e-10))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn rank_100x100(bh: &mut Bencher) {
|
||||
fn rank_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(100, 100);
|
||||
bh.iter(|| test::black_box(m.rank(1.0e-10)))
|
||||
bh.bench_function("rank_100x100", move |bh| bh.iter(|| test::black_box(m.rank(1.0e-10))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn rank_200x200(bh: &mut Bencher) {
|
||||
fn rank_200x200(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(200, 200);
|
||||
bh.iter(|| test::black_box(m.rank(1.0e-10)))
|
||||
bh.bench_function("rank_200x200", move |bh| bh.iter(|| test::black_box(m.rank(1.0e-10))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn singular_values_4x4(bh: &mut Bencher) {
|
||||
fn singular_values_4x4(bh: &mut criterion::Criterion) {
|
||||
let m = Matrix4::<f64>::new_random();
|
||||
bh.iter(|| test::black_box(m.singular_values()))
|
||||
bh.bench_function("singular_values_4x4", move |bh| bh.iter(|| test::black_box(m.singular_values())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn singular_values_10x10(bh: &mut Bencher) {
|
||||
fn singular_values_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(10, 10);
|
||||
bh.iter(|| test::black_box(m.singular_values()))
|
||||
bh.bench_function("singular_values_10x10", move |bh| bh.iter(|| test::black_box(m.singular_values())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn singular_values_100x100(bh: &mut Bencher) {
|
||||
fn singular_values_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(100, 100);
|
||||
bh.iter(|| test::black_box(m.singular_values()))
|
||||
bh.bench_function("singular_values_100x100", move |bh| bh.iter(|| test::black_box(m.singular_values())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn singular_values_200x200(bh: &mut Bencher) {
|
||||
fn singular_values_200x200(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(200, 200);
|
||||
bh.iter(|| test::black_box(m.singular_values()))
|
||||
bh.bench_function("singular_values_200x200", move |bh| bh.iter(|| test::black_box(m.singular_values())));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn pseudo_inverse_4x4(bh: &mut Bencher) {
|
||||
fn pseudo_inverse_4x4(bh: &mut criterion::Criterion) {
|
||||
let m = Matrix4::<f64>::new_random();
|
||||
bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10)))
|
||||
bh.bench_function("pseudo_inverse_4x4", move |bh| bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn pseudo_inverse_10x10(bh: &mut Bencher) {
|
||||
fn pseudo_inverse_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(10, 10);
|
||||
bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10)))
|
||||
bh.bench_function("pseudo_inverse_10x10", move |bh| bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn pseudo_inverse_100x100(bh: &mut Bencher) {
|
||||
fn pseudo_inverse_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(100, 100);
|
||||
bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10)))
|
||||
bh.bench_function("pseudo_inverse_100x100", move |bh| bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn pseudo_inverse_200x200(bh: &mut Bencher) {
|
||||
fn pseudo_inverse_200x200(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(200, 200);
|
||||
bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10)))
|
||||
bh.bench_function("pseudo_inverse_200x200", move |bh| bh.iter(|| test::black_box(m.clone().pseudo_inverse(1.0e-10))));
|
||||
}
|
||||
|
||||
|
||||
criterion_group!(svd,
|
||||
svd_decompose_4x4,
|
||||
svd_decompose_10x10,
|
||||
svd_decompose_100x100,
|
||||
svd_decompose_200x200,
|
||||
rank_4x4,
|
||||
rank_10x10,
|
||||
rank_100x100,
|
||||
rank_200x200,
|
||||
singular_values_4x4,
|
||||
singular_values_10x10,
|
||||
singular_values_100x100,
|
||||
singular_values_200x200,
|
||||
pseudo_inverse_4x4,
|
||||
pseudo_inverse_10x10,
|
||||
pseudo_inverse_100x100,
|
||||
pseudo_inverse_200x200
|
||||
);
|
|
@ -1,26 +1,28 @@
|
|||
use na::{Matrix4, SymmetricEigen};
|
||||
use test::{self, Bencher};
|
||||
|
||||
#[bench]
|
||||
fn symmetric_eigen_decompose_4x4(bh: &mut Bencher) {
|
||||
fn symmetric_eigen_decompose_4x4(bh: &mut criterion::Criterion) {
|
||||
let m = Matrix4::<f64>::new_random();
|
||||
bh.iter(|| test::black_box(SymmetricEigen::new(m.clone())))
|
||||
bh.bench_function("symmetric_eigen_decompose_4x4", move |bh| bh.iter(|| test::black_box(SymmetricEigen::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn symmetric_eigen_decompose_10x10(bh: &mut Bencher) {
|
||||
fn symmetric_eigen_decompose_10x10(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(10, 10);
|
||||
bh.iter(|| test::black_box(SymmetricEigen::new(m.clone())))
|
||||
bh.bench_function("symmetric_eigen_decompose_10x10", move |bh| bh.iter(|| test::black_box(SymmetricEigen::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn symmetric_eigen_decompose_100x100(bh: &mut Bencher) {
|
||||
fn symmetric_eigen_decompose_100x100(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(100, 100);
|
||||
bh.iter(|| test::black_box(SymmetricEigen::new(m.clone())))
|
||||
bh.bench_function("symmetric_eigen_decompose_100x100", move |bh| bh.iter(|| test::black_box(SymmetricEigen::new(m.clone()))));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn symmetric_eigen_decompose_200x200(bh: &mut Bencher) {
|
||||
fn symmetric_eigen_decompose_200x200(bh: &mut criterion::Criterion) {
|
||||
let m = crate::reproductible_dmatrix(200, 200);
|
||||
bh.iter(|| test::black_box(SymmetricEigen::new(m.clone())))
|
||||
bh.bench_function("symmetric_eigen_decompose_200x200", move |bh| bh.iter(|| test::black_box(SymmetricEigen::new(m.clone()))));
|
||||
}
|
||||
|
||||
criterion_group!(symmetric_eigen,
|
||||
symmetric_eigen_decompose_4x4,
|
||||
symmetric_eigen_decompose_10x10,
|
||||
symmetric_eigen_decompose_100x100,
|
||||
symmetric_eigen_decompose_200x200
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue