Skip to content

Commit 2680794

Browse files
committed
Use bench_with_input
1 parent 1aeb4c1 commit 2680794

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

benches/eigh.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ use ndarray_linalg::*;
44

55
fn eigh_small(c: &mut Criterion) {
66
let mut group = c.benchmark_group("eigh");
7-
87
for &n in &[4, 8, 16, 32, 64, 128] {
9-
group.bench_function(&format!("eigh{:03}", n), |b| {
10-
let a: Array2<f64> = random((n, n));
8+
group.bench_with_input(BenchmarkId::new("eigh", n), &n, |b, n| {
9+
let a: Array2<f64> = random((*n, *n));
1110
b.iter(|| {
1211
let (_e, _vecs) = a.eigh(UPLO::Upper).unwrap();
1312
})
1413
});
15-
group.bench_function(&format!("eigh{:03}_t", n), |b| {
16-
let a: Array2<f64> = random((n, n).f());
14+
group.bench_with_input(BenchmarkId::new("eigh_t", n), &n, |b, n| {
15+
let a: Array2<f64> = random((*n, *n).f());
1716
b.iter(|| {
1817
let (_e, _vecs) = a.eigh(UPLO::Upper).unwrap();
1918
})

benches/truncated_eig.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ use ndarray_linalg::*;
55
fn truncated_eigh_small(c: &mut Criterion) {
66
let mut group = c.benchmark_group("truncated_eigh");
77
for &n in &[4, 8, 16, 32, 64, 128] {
8-
group.bench_function(&format!("truncated_eig{:03}", n), |b| {
8+
group.bench_with_input(BenchmarkId::new("truncated_eig", n), &n, |b, &n| {
99
let a: Array2<f64> = random((n, n));
1010
let a = a.t().dot(&a);
1111
b.iter(move || {
1212
let _result = TruncatedEig::new(a.clone(), TruncatedOrder::Largest).decompose(1);
1313
})
1414
});
15-
group.bench_function(&format!("truncated_eig{:03}_t", n), |b| {
15+
group.bench_with_input(BenchmarkId::new("truncated_eig_t", n), &n, |b, &n| {
1616
let a: Array2<f64> = random((n, n).f());
1717
let a = a.t().dot(&a);
1818
b.iter(|| {

0 commit comments

Comments
 (0)