Added Benchmark
This commit is contained in:
parent
bffd99fb8a
commit
bfc112e9f3
@ -66,6 +66,11 @@ if(ENABLE_CONAN)
|
|||||||
run_conan()
|
run_conan()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(ENABLE_BENCH "Build the Benchmarks" ON)
|
||||||
|
if(ENABLE_BENCH)
|
||||||
|
add_subdirectory(benchmark)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_TESTING)
|
if(ENABLE_TESTING)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
message("Building Tests.")
|
message("Building Tests.")
|
||||||
|
15
benchmark/CMakeLists.txt
Normal file
15
benchmark/CMakeLists.txt
Normal 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
32
benchmark/bench.cpp
Normal 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);
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user