Port bidiagonalization benchmark to criterion.

This commit is contained in:
sebcrozet 2019-03-23 18:15:15 +01:00
parent 6d76249d74
commit dabff333e7
3 changed files with 38 additions and 34 deletions

View File

@ -22,4 +22,4 @@ 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);
criterion_main!(core::matrix::matrix, core::vector::vector, linalg::bidiagonal);

View File

@ -1,73 +1,75 @@
use na::{Bidiagonal, DMatrix, Matrix4};
use test::{self, Bencher};
#[path = "../common/macros.rs"]
mod macros;
// Without unpack.
#[bench]
fn bidiagonalize_100x100(bh: &mut Bencher) {
fn bidiagonalize_100x100(bh: &mut criterion::Criterion) {
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 Bencher) {
fn bidiagonalize_100x500(bh: &mut criterion::Criterion) {
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 Bencher) {
fn bidiagonalize_4x4(bh: &mut criterion::Criterion) {
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 Bencher) {
fn bidiagonalize_500x100(bh: &mut criterion::Criterion) {
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 Bencher) {
fn bidiagonalize_500x500(bh: &mut criterion::Criterion) {
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.
#[bench]
fn bidiagonalize_unpack_100x100(bh: &mut Bencher) {
fn bidiagonalize_unpack_100x100(bh: &mut criterion::Criterion) {
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.unpack();
})
}));
}
#[bench]
fn bidiagonalize_unpack_100x500(bh: &mut Bencher) {
fn bidiagonalize_unpack_100x500(bh: &mut criterion::Criterion) {
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.unpack();
})
}));
}
#[bench]
fn bidiagonalize_unpack_500x100(bh: &mut Bencher) {
fn bidiagonalize_unpack_500x100(bh: &mut criterion::Criterion) {
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.unpack();
})
}));
}
#[bench]
fn bidiagonalize_unpack_500x500(bh: &mut Bencher) {
fn bidiagonalize_unpack_500x500(bh: &mut criterion::Criterion) {
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.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
);

View File

@ -1,3 +1,5 @@
pub use self::bidiagonal::bidiagonal;
mod bidiagonal;
mod cholesky;
mod full_piv_lu;