Added Benchmark

This commit is contained in:
Jacob Holder 2021-10-24 19:55:20 +02:00
parent bffd99fb8a
commit bfc112e9f3
Signed by: jacob
GPG Key ID: 2194FC747048A7FD
3 changed files with 52 additions and 0 deletions

View File

@ -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.")

15
benchmark/CMakeLists.txt Normal file
View File

@ -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
)

32
benchmark/bench.cpp Normal file
View File

@ -0,0 +1,32 @@
//
// Created by jholder on 24.10.21.
//
#define CATCH_CONFIG_MAIN
#define CATCH_CONFIG_ENABLE_BENCHMARKING
#include <catch2/catch.hpp>
#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);
};
}