| 1 |
use na::{DMatrix, Hessenberg, Matrix4}; |
| 2 |
|
| 3 |
#[path = "../common/macros.rs"] |
| 4 |
mod macros; |
| 5 |
|
| 6 |
// Without unpack. |
| 7 |
fn hessenberg_decompose_4x4(bh: &mut criterion::Criterion) { |
| 8 |
let m = Matrix4::<f64>::new_random(); |
| 9 |
bh.bench_function("hessenberg_decompose_4x4", move |bh| { |
| 10 |
bh.iter(|| std::hint::black_box(Hessenberg::new(m.clone()))) |
| 11 |
}); |
| 12 |
} |
| 13 |
|
| 14 |
fn hessenberg_decompose_100x100(bh: &mut criterion::Criterion) { |
| 15 |
let m = DMatrix::<f64>::new_random(100, 100); |
| 16 |
bh.bench_function("hessenberg_decompose_100x100", move |bh| { |
| 17 |
bh.iter(|| std::hint::black_box(Hessenberg::new(m.clone()))) |
| 18 |
}); |
| 19 |
} |
| 20 |
|
| 21 |
fn hessenberg_decompose_200x200(bh: &mut criterion::Criterion) { |
| 22 |
let m = DMatrix::<f64>::new_random(200, 200); |
| 23 |
bh.bench_function("hessenberg_decompose_200x200", move |bh| { |
| 24 |
bh.iter(|| std::hint::black_box(Hessenberg::new(m.clone()))) |
| 25 |
}); |
| 26 |
} |
| 27 |
|
| 28 |
// With unpack. |
| 29 |
fn hessenberg_decompose_unpack_100x100(bh: &mut criterion::Criterion) { |
| 30 |
let m = DMatrix::<f64>::new_random(100, 100); |
| 31 |
bh.bench_function("hessenberg_decompose_unpack_100x100", move |bh| { |
| 32 |
bh.iter(|| { |
| 33 |
let hess = Hessenberg::new(m.clone()); |
| 34 |
let _ = hess.unpack(); |
| 35 |
}) |
| 36 |
}); |
| 37 |
} |
| 38 |
|
| 39 |
fn hessenberg_decompose_unpack_200x200(bh: &mut criterion::Criterion) { |
| 40 |
let m = DMatrix::<f64>::new_random(200, 200); |
| 41 |
bh.bench_function("hessenberg_decompose_unpack_200x200", move |bh| { |
| 42 |
bh.iter(|| { |
| 43 |
let hess = Hessenberg::new(m.clone()); |
| 44 |
let _ = hess.unpack(); |
| 45 |
}) |
| 46 |
}); |
| 47 |
} |
| 48 |
|
| 49 |
criterion_group!( |
| 50 |
hessenberg, |
| 51 |
hessenberg_decompose_4x4, |
| 52 |
hessenberg_decompose_100x100, |
| 53 |
hessenberg_decompose_200x200, |
| 54 |
hessenberg_decompose_unpack_100x100, |
| 55 |
hessenberg_decompose_unpack_200x200, |
| 56 |
); |