|
| 1 | +use criterion::*; |
| 2 | +use ndarray::*; |
| 3 | +use ndarray_linalg::*; |
| 4 | + |
| 5 | +fn svd_small(c: &mut Criterion) { |
| 6 | + let mut group = c.benchmark_group("svd"); |
| 7 | + for &n in &[4, 8, 16, 32, 64, 128] { |
| 8 | + group.bench_with_input(BenchmarkId::new("C", n), &n, |b, n| { |
| 9 | + let a: Array2<f64> = random((*n, *n)); |
| 10 | + b.iter(|| { |
| 11 | + let _ = a.svd(false, false).unwrap(); |
| 12 | + }) |
| 13 | + }); |
| 14 | + group.bench_with_input(BenchmarkId::new("F", n), &n, |b, n| { |
| 15 | + let a: Array2<f64> = random((*n, *n).f()); |
| 16 | + b.iter(|| { |
| 17 | + let _ = a.svd(false, false).unwrap(); |
| 18 | + }) |
| 19 | + }); |
| 20 | + group.bench_with_input(BenchmarkId::new("u/C", n), &n, |b, n| { |
| 21 | + let a: Array2<f64> = random((*n, *n)); |
| 22 | + b.iter(|| { |
| 23 | + let _ = a.svd(true, false).unwrap(); |
| 24 | + }) |
| 25 | + }); |
| 26 | + group.bench_with_input(BenchmarkId::new("u/F", n), &n, |b, n| { |
| 27 | + let a: Array2<f64> = random((*n, *n).f()); |
| 28 | + b.iter(|| { |
| 29 | + let _ = a.svd(true, false).unwrap(); |
| 30 | + }) |
| 31 | + }); |
| 32 | + group.bench_with_input(BenchmarkId::new("vt/C", n), &n, |b, n| { |
| 33 | + let a: Array2<f64> = random((*n, *n)); |
| 34 | + b.iter(|| { |
| 35 | + let _ = a.svd(false, true).unwrap(); |
| 36 | + }) |
| 37 | + }); |
| 38 | + group.bench_with_input(BenchmarkId::new("vt/F", n), &n, |b, n| { |
| 39 | + let a: Array2<f64> = random((*n, *n).f()); |
| 40 | + b.iter(|| { |
| 41 | + let _ = a.svd(false, true).unwrap(); |
| 42 | + }) |
| 43 | + }); |
| 44 | + group.bench_with_input(BenchmarkId::new("uvt/C", n), &n, |b, n| { |
| 45 | + let a: Array2<f64> = random((*n, *n)); |
| 46 | + b.iter(|| { |
| 47 | + let _ = a.svd(false, true).unwrap(); |
| 48 | + }) |
| 49 | + }); |
| 50 | + group.bench_with_input(BenchmarkId::new("uvt/F", n), &n, |b, n| { |
| 51 | + let a: Array2<f64> = random((*n, *n).f()); |
| 52 | + b.iter(|| { |
| 53 | + let _ = a.svd(false, true).unwrap(); |
| 54 | + }) |
| 55 | + }); |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +criterion_group!(svd, svd_small); |
| 60 | +criterion_main!(svd); |
0 commit comments