Skip to content

Commit 1aeb4c1

Browse files
committed
Enable grouping for truncated_eigh
1 parent 001a46a commit 1aeb4c1

File tree

2 files changed

+23
-38
lines changed

2 files changed

+23
-38
lines changed

benches/eigh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ fn eigh_small(c: &mut Criterion) {
66
let mut group = c.benchmark_group("eigh");
77

88
for &n in &[4, 8, 16, 32, 64, 128] {
9-
group.bench_function(&format!("eigh{}", n), |b| {
9+
group.bench_function(&format!("eigh{:03}", n), |b| {
1010
let a: Array2<f64> = random((n, n));
1111
b.iter(|| {
1212
let (_e, _vecs) = a.eigh(UPLO::Upper).unwrap();
1313
})
1414
});
15-
group.bench_function(&format!("eigh{}_t", n), |b| {
15+
group.bench_function(&format!("eigh{:03}_t", n), |b| {
1616
let a: Array2<f64> = random((n, n).f());
1717
b.iter(|| {
1818
let (_e, _vecs) = a.eigh(UPLO::Upper).unwrap();

benches/truncated_eig.rs

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,26 @@
1-
#[macro_use]
2-
extern crate criterion;
3-
4-
use criterion::Criterion;
1+
use criterion::*;
52
use ndarray::*;
63
use ndarray_linalg::*;
74

8-
macro_rules! impl_teig {
9-
($n:expr) => {
10-
paste::item! {
11-
fn [<teig $n>](c: &mut Criterion) {
12-
c.bench_function(&format!("truncated_eig{}", $n), |b| {
13-
let a: Array2<f64> = random(($n, $n));
14-
let a = a.t().dot(&a);
15-
16-
b.iter(move || {
17-
let _result = TruncatedEig::new(a.clone(), TruncatedOrder::Largest).decompose(1);
18-
})
19-
});
20-
c.bench_function(&format!("truncated_eig{}_t", $n), |b| {
21-
let a: Array2<f64> = random(($n, $n).f());
22-
let a = a.t().dot(&a);
23-
24-
b.iter(|| {
25-
let _result = TruncatedEig::new(a.clone(), TruncatedOrder::Largest).decompose(1);
26-
})
27-
});
28-
}
29-
}
30-
};
5+
fn truncated_eigh_small(c: &mut Criterion) {
6+
let mut group = c.benchmark_group("truncated_eigh");
7+
for &n in &[4, 8, 16, 32, 64, 128] {
8+
group.bench_function(&format!("truncated_eig{:03}", n), |b| {
9+
let a: Array2<f64> = random((n, n));
10+
let a = a.t().dot(&a);
11+
b.iter(move || {
12+
let _result = TruncatedEig::new(a.clone(), TruncatedOrder::Largest).decompose(1);
13+
})
14+
});
15+
group.bench_function(&format!("truncated_eig{:03}_t", n), |b| {
16+
let a: Array2<f64> = random((n, n).f());
17+
let a = a.t().dot(&a);
18+
b.iter(|| {
19+
let _result = TruncatedEig::new(a.clone(), TruncatedOrder::Largest).decompose(1);
20+
})
21+
});
22+
}
3123
}
3224

33-
impl_teig!(4);
34-
impl_teig!(8);
35-
impl_teig!(16);
36-
impl_teig!(32);
37-
impl_teig!(64);
38-
impl_teig!(128);
39-
40-
criterion_group!(teig, teig4, teig8, teig16, teig32, teig64, teig128);
41-
criterion_main!(teig);
25+
criterion_group!(truncated_eigh, truncated_eigh_small);
26+
criterion_main!(truncated_eigh);

0 commit comments

Comments
 (0)