Skip to content

Commit 6133488

Browse files
authored
Merge pull request #169 from rust-ndarray/benchmarking
Add benchmark of eigh
2 parents 7685117 + 60ee339 commit 6133488

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,8 @@ optional = true
4949

5050
[dev-dependencies]
5151
paste = "0.1"
52+
criterion = "*"
53+
54+
[[bench]]
55+
name = "eigh"
56+
harness = false

benches/eigh.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#[macro_use]
2+
extern crate criterion;
3+
4+
use criterion::Criterion;
5+
use ndarray::*;
6+
use ndarray_linalg::*;
7+
8+
macro_rules! impl_eigh {
9+
($n:expr) => {
10+
paste::item! {
11+
fn [<eigh $n>](c: &mut Criterion) {
12+
c.bench_function(&format!("eigh{}", $n), |b| {
13+
let a: Array2<f64> = random(($n, $n));
14+
b.iter(|| {
15+
let (_e, _vecs) = a.eigh(UPLO::Upper).unwrap();
16+
})
17+
});
18+
c.bench_function(&format!("eigh{}_t", $n), |b| {
19+
let a: Array2<f64> = random(($n, $n).f());
20+
b.iter(|| {
21+
let (_e, _vecs) = a.eigh(UPLO::Upper).unwrap();
22+
})
23+
});
24+
}
25+
}
26+
};
27+
}
28+
29+
impl_eigh!(4);
30+
impl_eigh!(8);
31+
impl_eigh!(16);
32+
impl_eigh!(32);
33+
impl_eigh!(64);
34+
impl_eigh!(128);
35+
36+
criterion_group!(eigh, eigh4, eigh8, eigh16, eigh32, eigh64, eigh128);
37+
criterion_main!(eigh);

0 commit comments

Comments
 (0)