Port bidiagonalization benchmark to criterion.
This commit is contained in:
parent
6d76249d74
commit
dabff333e7
|
@ -22,4 +22,4 @@ fn reproductible_dmatrix(nrows: usize, ncols: usize) -> DMatrix<f64> {
|
||||||
DMatrix::<f64>::from_fn(nrows, ncols, |_, _| rng.gen())
|
DMatrix::<f64>::from_fn(nrows, ncols, |_, _| rng.gen())
|
||||||
}
|
}
|
||||||
|
|
||||||
criterion_main!(core::matrix::matrix, core::vector::vector);
|
criterion_main!(core::matrix::matrix, core::vector::vector, linalg::bidiagonal);
|
|
@ -1,73 +1,75 @@
|
||||||
use na::{Bidiagonal, DMatrix, Matrix4};
|
use na::{Bidiagonal, DMatrix, Matrix4};
|
||||||
use test::{self, Bencher};
|
|
||||||
|
|
||||||
#[path = "../common/macros.rs"]
|
#[path = "../common/macros.rs"]
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
// Without unpack.
|
// Without unpack.
|
||||||
#[bench]
|
fn bidiagonalize_100x100(bh: &mut criterion::Criterion) {
|
||||||
fn bidiagonalize_100x100(bh: &mut Bencher) {
|
|
||||||
let m = DMatrix::<f64>::new_random(100, 100);
|
let m = DMatrix::<f64>::new_random(100, 100);
|
||||||
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
|
bh.bench_function("bidiagonalize_100x100", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
fn bidiagonalize_100x500(bh: &mut criterion::Criterion) {
|
||||||
fn bidiagonalize_100x500(bh: &mut Bencher) {
|
|
||||||
let m = DMatrix::<f64>::new_random(100, 500);
|
let m = DMatrix::<f64>::new_random(100, 500);
|
||||||
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
|
bh.bench_function("bidiagonalize_100x500", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
fn bidiagonalize_4x4(bh: &mut criterion::Criterion) {
|
||||||
fn bidiagonalize_4x4(bh: &mut Bencher) {
|
|
||||||
let m = Matrix4::<f64>::new_random();
|
let m = Matrix4::<f64>::new_random();
|
||||||
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
|
bh.bench_function("bidiagonalize_4x4", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
fn bidiagonalize_500x100(bh: &mut criterion::Criterion) {
|
||||||
fn bidiagonalize_500x100(bh: &mut Bencher) {
|
|
||||||
let m = DMatrix::<f64>::new_random(500, 100);
|
let m = DMatrix::<f64>::new_random(500, 100);
|
||||||
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
|
bh.bench_function("bidiagonalize_500x100", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
fn bidiagonalize_500x500(bh: &mut criterion::Criterion) {
|
||||||
fn bidiagonalize_500x500(bh: &mut Bencher) {
|
|
||||||
let m = DMatrix::<f64>::new_random(500, 500);
|
let m = DMatrix::<f64>::new_random(500, 500);
|
||||||
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
|
bh.bench_function("bidiagonalize_500x500", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// With unpack.
|
// With unpack.
|
||||||
#[bench]
|
fn bidiagonalize_unpack_100x100(bh: &mut criterion::Criterion) {
|
||||||
fn bidiagonalize_unpack_100x100(bh: &mut Bencher) {
|
|
||||||
let m = DMatrix::<f64>::new_random(100, 100);
|
let m = DMatrix::<f64>::new_random(100, 100);
|
||||||
bh.iter(|| {
|
bh.bench_function("bidiagonalize_unpack_100x100", move |bh| bh.iter(|| {
|
||||||
let bidiag = Bidiagonal::new(m.clone());
|
let bidiag = Bidiagonal::new(m.clone());
|
||||||
let _ = bidiag.unpack();
|
let _ = bidiag.unpack();
|
||||||
})
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
fn bidiagonalize_unpack_100x500(bh: &mut criterion::Criterion) {
|
||||||
fn bidiagonalize_unpack_100x500(bh: &mut Bencher) {
|
|
||||||
let m = DMatrix::<f64>::new_random(100, 500);
|
let m = DMatrix::<f64>::new_random(100, 500);
|
||||||
bh.iter(|| {
|
bh.bench_function("bidiagonalize_unpack_100x500", move |bh| bh.iter(|| {
|
||||||
let bidiag = Bidiagonal::new(m.clone());
|
let bidiag = Bidiagonal::new(m.clone());
|
||||||
let _ = bidiag.unpack();
|
let _ = bidiag.unpack();
|
||||||
})
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
fn bidiagonalize_unpack_500x100(bh: &mut criterion::Criterion) {
|
||||||
fn bidiagonalize_unpack_500x100(bh: &mut Bencher) {
|
|
||||||
let m = DMatrix::<f64>::new_random(500, 100);
|
let m = DMatrix::<f64>::new_random(500, 100);
|
||||||
bh.iter(|| {
|
bh.bench_function("bidiagonalize_unpack_500x100", move |bh| bh.iter(|| {
|
||||||
let bidiag = Bidiagonal::new(m.clone());
|
let bidiag = Bidiagonal::new(m.clone());
|
||||||
let _ = bidiag.unpack();
|
let _ = bidiag.unpack();
|
||||||
})
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[bench]
|
fn bidiagonalize_unpack_500x500(bh: &mut criterion::Criterion) {
|
||||||
fn bidiagonalize_unpack_500x500(bh: &mut Bencher) {
|
|
||||||
let m = DMatrix::<f64>::new_random(500, 500);
|
let m = DMatrix::<f64>::new_random(500, 500);
|
||||||
bh.iter(|| {
|
bh.bench_function("bidiagonalize_unpack_500x500", move |bh| bh.iter(|| {
|
||||||
let bidiag = Bidiagonal::new(m.clone());
|
let bidiag = Bidiagonal::new(m.clone());
|
||||||
let _ = bidiag.unpack();
|
let _ = bidiag.unpack();
|
||||||
})
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
criterion_group!(bidiagonal,
|
||||||
|
bidiagonalize_100x100,
|
||||||
|
bidiagonalize_100x500,
|
||||||
|
bidiagonalize_4x4,
|
||||||
|
bidiagonalize_500x100,
|
||||||
|
bidiagonalize_500x500,
|
||||||
|
bidiagonalize_unpack_100x100,
|
||||||
|
bidiagonalize_unpack_100x500,
|
||||||
|
bidiagonalize_unpack_500x100,
|
||||||
|
bidiagonalize_unpack_500x500
|
||||||
|
);
|
|
@ -1,3 +1,5 @@
|
||||||
|
pub use self::bidiagonal::bidiagonal;
|
||||||
|
|
||||||
mod bidiagonal;
|
mod bidiagonal;
|
||||||
mod cholesky;
|
mod cholesky;
|
||||||
mod full_piv_lu;
|
mod full_piv_lu;
|
||||||
|
|
Loading…
Reference in New Issue