| 1 |
use na::{DMatrix, DVector}; |
| 2 |
|
| 3 |
fn solve_l_triangular_100x100(bh: &mut criterion::Criterion) { |
| 4 |
let m = DMatrix::<f64>::new_random(100, 100); |
| 5 |
let v = DVector::<f64>::new_random(100); |
| 6 |
|
| 7 |
bh.bench_function("solve_l_triangular_100x100", move |bh| { |
| 8 |
bh.iter(|| { |
| 9 |
let _ = m.solve_lower_triangular(&v); |
| 10 |
}) |
| 11 |
}); |
| 12 |
} |
| 13 |
|
| 14 |
fn solve_l_triangular_1000x1000(bh: &mut criterion::Criterion) { |
| 15 |
let m = DMatrix::<f64>::new_random(1000, 1000); |
| 16 |
let v = DVector::<f64>::new_random(1000); |
| 17 |
|
| 18 |
bh.bench_function("solve_l_triangular_1000x1000", move |bh| { |
| 19 |
bh.iter(|| { |
| 20 |
let _ = m.solve_lower_triangular(&v); |
| 21 |
}) |
| 22 |
}); |
| 23 |
} |
| 24 |
|
| 25 |
fn tr_solve_l_triangular_100x100(bh: &mut criterion::Criterion) { |
| 26 |
let m = DMatrix::<f64>::new_random(100, 100); |
| 27 |
let v = DVector::<f64>::new_random(100); |
| 28 |
|
| 29 |
bh.bench_function("tr_solve_l_triangular_100x100", move |bh| { |
| 30 |
bh.iter(|| { |
| 31 |
let _ = m.tr_solve_lower_triangular(&v); |
| 32 |
}) |
| 33 |
}); |
| 34 |
} |
| 35 |
|
| 36 |
fn tr_solve_l_triangular_1000x1000(bh: &mut criterion::Criterion) { |
| 37 |
let m = DMatrix::<f64>::new_random(1000, 1000); |
| 38 |
let v = DVector::<f64>::new_random(1000); |
| 39 |
|
| 40 |
bh.bench_function("tr_solve_l_triangular_1000x1000", move |bh| { |
| 41 |
bh.iter(|| { |
| 42 |
let _ = m.tr_solve_lower_triangular(&v); |
| 43 |
}) |
| 44 |
}); |
| 45 |
} |
| 46 |
|
| 47 |
fn solve_u_triangular_100x100(bh: &mut criterion::Criterion) { |
| 48 |
let m = DMatrix::<f64>::new_random(100, 100); |
| 49 |
let v = DVector::<f64>::new_random(100); |
| 50 |
|
| 51 |
bh.bench_function("solve_u_triangular_100x100", move |bh| { |
| 52 |
bh.iter(|| { |
| 53 |
let _ = m.solve_upper_triangular(&v); |
| 54 |
}) |
| 55 |
}); |
| 56 |
} |
| 57 |
|
| 58 |
fn solve_u_triangular_1000x1000(bh: &mut criterion::Criterion) { |
| 59 |
let m = DMatrix::<f64>::new_random(1000, 1000); |
| 60 |
let v = DVector::<f64>::new_random(1000); |
| 61 |
|
| 62 |
bh.bench_function("solve_u_triangular_1000x1000", move |bh| { |
| 63 |
bh.iter(|| { |
| 64 |
let _ = m.solve_upper_triangular(&v); |
| 65 |
}) |
| 66 |
}); |
| 67 |
} |
| 68 |
|
| 69 |
fn tr_solve_u_triangular_100x100(bh: &mut criterion::Criterion) { |
| 70 |
let m = DMatrix::<f64>::new_random(100, 100); |
| 71 |
let v = DVector::<f64>::new_random(100); |
| 72 |
|
| 73 |
bh.bench_function("tr_solve_u_triangular_100x100", move |bh| { |
| 74 |
bh.iter(|| { |
| 75 |
let _ = m.tr_solve_upper_triangular(&v); |
| 76 |
}) |
| 77 |
}); |
| 78 |
} |
| 79 |
|
| 80 |
fn tr_solve_u_triangular_1000x1000(bh: &mut criterion::Criterion) { |
| 81 |
let m = DMatrix::<f64>::new_random(1000, 1000); |
| 82 |
let v = DVector::<f64>::new_random(1000); |
| 83 |
|
| 84 |
bh.bench_function("tr_solve_u_triangular_1000x1000", move |bh| { |
| 85 |
bh.iter(|| { |
| 86 |
let _ = m.tr_solve_upper_triangular(&v); |
| 87 |
}) |
| 88 |
}); |
| 89 |
} |
| 90 |
|
| 91 |
criterion_group!( |
| 92 |
solve, |
| 93 |
solve_l_triangular_100x100, |
| 94 |
solve_l_triangular_1000x1000, |
| 95 |
tr_solve_l_triangular_100x100, |
| 96 |
tr_solve_l_triangular_1000x1000, |
| 97 |
solve_u_triangular_100x100, |
| 98 |
solve_u_triangular_1000x1000, |
| 99 |
tr_solve_u_triangular_100x100, |
| 100 |
tr_solve_u_triangular_1000x1000 |
| 101 |
); |