From c36dcc4e6d638456c337766c16e2968bde471868 Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Mon, 20 Apr 2020 21:33:54 +0200 Subject: [PATCH] add sbp xi/eta benches --- sbp/Cargo.toml | 4 +++ sbp/benches/sbpoperators.rs | 52 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 sbp/benches/sbpoperators.rs diff --git a/sbp/Cargo.toml b/sbp/Cargo.toml index 8a7bec5..165f71f 100644 --- a/sbp/Cargo.toml +++ b/sbp/Cargo.toml @@ -27,3 +27,7 @@ harness = false [[bench]] name = "euler" harness = false + +[[bench]] +name = "sbpoperators" +harness = false diff --git a/sbp/benches/sbpoperators.rs b/sbp/benches/sbpoperators.rs new file mode 100644 index 0000000..19b9eae --- /dev/null +++ b/sbp/benches/sbpoperators.rs @@ -0,0 +1,52 @@ +use criterion::{criterion_group, criterion_main, Criterion}; +use sbp::operators::{self, SbpOperator2d}; +use sbp::Float; + +fn performance_benchmark(c: &mut Criterion) { + let mut group = c.benchmark_group("SBPoperators"); + group.sample_size(25); + + let w = 64; + let h = 64; + + let x = ndarray::Array2::from_shape_fn((w, h), |(j, i)| (j * h + i) as Float); + + group.bench_function("upwind4 diffxi", |b| { + let mut res = x.clone(); + b.iter(|| operators::Upwind4.diffxi(x.view(), res.view_mut())) + }); + group.bench_function("upwind9 diffxi", |b| { + let mut res = x.clone(); + b.iter(|| operators::Upwind9.diffxi(x.view(), res.view_mut())) + }); + group.bench_function("trad4 diffxi", |b| { + let mut res = x.clone(); + b.iter(|| operators::SBP4.diffxi(x.view(), res.view_mut())) + }); + group.bench_function("trad8 diffxi", |b| { + let mut res = x.clone(); + b.iter(|| operators::SBP8.diffxi(x.view(), res.view_mut())) + }); + + group.bench_function("upwind4 diffeta", |b| { + let mut res = x.clone(); + b.iter(|| operators::Upwind4.diffeta(x.view(), res.view_mut())) + }); + group.bench_function("upwind9 diffeta", |b| { + let mut res = x.clone(); + b.iter(|| operators::Upwind9.diffeta(x.view(), res.view_mut())) + }); + group.bench_function("trad4 diffeta", |b| { + let mut res = x.clone(); + b.iter(|| operators::SBP4.diffeta(x.view(), res.view_mut())) + }); + group.bench_function("trad8 diffeta", |b| { + let mut res = x.clone(); + b.iter(|| operators::SBP8.diffeta(x.view(), res.view_mut())) + }); + + group.finish(); +} + +criterion_group!(benches, performance_benchmark); +criterion_main!(benches);