2018-02-02 19:26:35 +08:00
|
|
|
use na::{Bidiagonal, DMatrix, Matrix4};
|
2017-08-03 01:37:44 +08:00
|
|
|
|
2018-02-02 19:26:35 +08:00
|
|
|
#[path = "../common/macros.rs"]
|
2017-08-03 01:37:44 +08:00
|
|
|
mod macros;
|
|
|
|
|
|
|
|
// Without unpack.
|
2019-03-24 01:15:15 +08:00
|
|
|
fn bidiagonalize_100x100(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(100, 100);
|
2019-03-24 01:15:15 +08:00
|
|
|
bh.bench_function("bidiagonalize_100x100", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 01:15:15 +08:00
|
|
|
fn bidiagonalize_100x500(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(100, 500);
|
2019-03-24 01:15:15 +08:00
|
|
|
bh.bench_function("bidiagonalize_100x500", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 01:15:15 +08:00
|
|
|
fn bidiagonalize_4x4(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = Matrix4::<f64>::new_random();
|
2019-03-24 01:15:15 +08:00
|
|
|
bh.bench_function("bidiagonalize_4x4", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 01:15:15 +08:00
|
|
|
fn bidiagonalize_500x100(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(500, 100);
|
2019-03-24 01:15:15 +08:00
|
|
|
bh.bench_function("bidiagonalize_500x100", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 01:15:15 +08:00
|
|
|
fn bidiagonalize_500x500(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(500, 500);
|
2019-03-24 01:15:15 +08:00
|
|
|
bh.bench_function("bidiagonalize_500x500", move |bh| bh.iter(|| test::black_box(Bidiagonal::new(m.clone()))));
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// With unpack.
|
2019-03-24 01:15:15 +08:00
|
|
|
fn bidiagonalize_unpack_100x100(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(100, 100);
|
2019-03-24 01:15:15 +08:00
|
|
|
bh.bench_function("bidiagonalize_unpack_100x100", move |bh| bh.iter(|| {
|
2017-08-03 01:37:44 +08:00
|
|
|
let bidiag = Bidiagonal::new(m.clone());
|
|
|
|
let _ = bidiag.unpack();
|
2019-03-24 01:15:15 +08:00
|
|
|
}));
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 01:15:15 +08:00
|
|
|
fn bidiagonalize_unpack_100x500(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(100, 500);
|
2019-03-24 01:15:15 +08:00
|
|
|
bh.bench_function("bidiagonalize_unpack_100x500", move |bh| bh.iter(|| {
|
2017-08-03 01:37:44 +08:00
|
|
|
let bidiag = Bidiagonal::new(m.clone());
|
|
|
|
let _ = bidiag.unpack();
|
2019-03-24 01:15:15 +08:00
|
|
|
}));
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 01:15:15 +08:00
|
|
|
fn bidiagonalize_unpack_500x100(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(500, 100);
|
2019-03-24 01:15:15 +08:00
|
|
|
bh.bench_function("bidiagonalize_unpack_500x100", move |bh| bh.iter(|| {
|
2017-08-03 01:37:44 +08:00
|
|
|
let bidiag = Bidiagonal::new(m.clone());
|
|
|
|
let _ = bidiag.unpack();
|
2019-03-24 01:15:15 +08:00
|
|
|
}));
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
|
|
|
|
2019-03-24 01:15:15 +08:00
|
|
|
fn bidiagonalize_unpack_500x500(bh: &mut criterion::Criterion) {
|
2017-08-03 01:37:44 +08:00
|
|
|
let m = DMatrix::<f64>::new_random(500, 500);
|
2019-03-24 01:15:15 +08:00
|
|
|
bh.bench_function("bidiagonalize_unpack_500x500", move |bh| bh.iter(|| {
|
2017-08-03 01:37:44 +08:00
|
|
|
let bidiag = Bidiagonal::new(m.clone());
|
|
|
|
let _ = bidiag.unpack();
|
2019-03-24 01:15:15 +08:00
|
|
|
}));
|
2017-08-03 01:37:44 +08:00
|
|
|
}
|
2019-03-24 01:15:15 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
);
|