From bfc112e9f3d9805b13a1a6bb19b0de7761c83be1 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sun, 24 Oct 2021 19:55:20 +0200 Subject: [PATCH] Added Benchmark --- CMakeLists.txt | 5 +++++ benchmark/CMakeLists.txt | 15 +++++++++++++++ benchmark/bench.cpp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 benchmark/CMakeLists.txt create mode 100644 benchmark/bench.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b16f771..450aa32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,11 @@ if(ENABLE_CONAN) run_conan() endif() +option(ENABLE_BENCH "Build the Benchmarks" ON) +if(ENABLE_BENCH) + add_subdirectory(benchmark) +endif() + if(ENABLE_TESTING) enable_testing() message("Building Tests.") diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt new file mode 100644 index 0000000..a412f63 --- /dev/null +++ b/benchmark/CMakeLists.txt @@ -0,0 +1,15 @@ + +find_package(Eigen3) +find_package(Catch2 REQUIRED) + +add_executable(benchmark bench.cpp) + +target_link_libraries( + benchmark + PRIVATE project_options + project_warnings + Eigen3::Eigen3 + Catch2::Catch2 + integratoren +) + diff --git a/benchmark/bench.cpp b/benchmark/bench.cpp new file mode 100644 index 0000000..cc11b46 --- /dev/null +++ b/benchmark/bench.cpp @@ -0,0 +1,32 @@ +// +// Created by jholder on 24.10.21. +// + +#define CATCH_CONFIG_MAIN +#define CATCH_CONFIG_ENABLE_BENCHMARKING + +#include +#include "Rod2d.hpp" +#include "Integratoren2d_forceless.h" + +TEST_CASE("Euler - Baseline", "[benchmark]") +{ + Rod2d rod(1.0); + Simulation sim(0.01, Catch::rngSeed()); + BENCHMARK("Euler without force") + { + Integratoren2d_forceless::Set1_Euler(rod, sim); + }; + BENCHMARK("Heun without force") + { + Integratoren2d_forceless::Set2_Heun(rod, sim); + }; + BENCHMARK("Exact without force") + { + Integratoren2d_forceless::Set3_Exact(rod, sim); + }; + BENCHMARK("BDAS without force") + { + Integratoren2d_forceless::Set4_BDAS(rod, sim); + }; +} \ No newline at end of file