Add benching of matrix creation

This commit is contained in:
Magnus Ulimoen 2020-08-21 22:53:37 +02:00
parent d00e7b3fb1
commit 3671ba5e1f
2 changed files with 44 additions and 1 deletions

View File

@ -69,5 +69,48 @@ fn performance_benchmark(c: &mut Criterion) {
group.finish();
}
#[cfg(feature = "sparse")]
fn sparse_creation(c: &mut Criterion) {
let mut group = c.benchmark_group("MaxwellSystem");
group.sample_size(25);
let w = 40;
let h = 26;
group.bench_function("create_rhs_trad4", |b| {
b.iter(|| {
let _matrix = maxwell::sparse::rhs_matrix(&SBP4, w, h);
})
});
group.bench_function("create_rhs_upwind4", |b| {
b.iter(|| {
let _matrix = maxwell::sparse::rhs_matrix(&sbp::operators::Upwind4, w, h);
})
});
group.bench_function("create_rhs_upwind9", |b| {
b.iter(|| {
let _matrix = maxwell::sparse::rhs_matrix(&sbp::operators::Upwind9, w, h);
})
});
group.bench_function("create_rhs_upwind_upwind4", |b| {
b.iter(|| {
let _matrix =
maxwell::sparse::rhs_matrix_with_upwind_dissipation(&sbp::operators::Upwind4, w, h);
})
});
group.bench_function("create_rhs_upwind_upwind9", |b| {
b.iter(|| {
let _matrix =
maxwell::sparse::rhs_matrix_with_upwind_dissipation(&sbp::operators::Upwind9, w, h);
})
});
}
#[cfg(feature = "sparse")]
criterion_group!(sparse_create, sparse_creation);
criterion_group!(benches, performance_benchmark);
#[cfg(feature = "sparse")]
criterion_main!(benches, sparse_create);
#[cfg(not(feature = "sparse"))]
criterion_main!(benches);

View File

@ -6,7 +6,7 @@ use sbp::operators::{SbpOperator2d, UpwindOperator2d};
use sbp::Float;
#[cfg(feature = "sparse")]
mod sparse;
pub mod sparse;
#[derive(Clone, Debug)]
pub struct Field(pub(crate) Array3<Float>);