diff --git a/CMakeLists.txt b/CMakeLists.txt index b3a72c3e53..213a51e1a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ include(CPack) include(CTest) include(GNUInstallDirs) +add_subdirectory("benchmark") add_subdirectory("cmake") add_subdirectory("include") add_subdirectory("linalg") diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index bac3a50ad8..48ec2cccc8 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -106,35 +106,3 @@ foreach(BACKEND IN ITEMS "eigen" "naive") endforeach() endforeach() endforeach() - -foreach(BACKEND IN ITEMS "eigen") - foreach(STATE_SIZE RANGE 1 2) - foreach(OUTPUT_SIZE RANGE 1 2) - configure_file(update_linalg_xx0.cpp - update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0.cpp) - add_executable( - kalman_benchmark_update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0_driver - update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0.cpp) - target_include_directories( - kalman_benchmark_update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0_driver - PRIVATE "include") - set_target_properties( - kalman_benchmark_update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0_driver - PROPERTIES CXX_STANDARD 23 - CXX_EXTENSIONS OFF - INTERPROCEDURAL_OPTIMIZATION TRUE) - target_link_libraries( - kalman_benchmark_update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0_driver - PRIVATE benchmark::benchmark benchmark::benchmark_main kalman - kalman_linalg_${BACKEND} kalman_options) - separate_arguments(TEST_COMMAND UNIX_COMMAND $ENV{COMMAND}) - add_test( - NAME kalman_benchmark_update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0 - COMMAND - ${TEST_COMMAND} - $ - "--benchmark_out=update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0.json" - ) - endforeach() - endforeach() -endforeach() diff --git a/benchmark/predict_1x1x0.cpp b/benchmark/predict_1x1x0.cpp index 81571c31d6..ed2f6f5041 100644 --- a/benchmark/predict_1x1x0.cpp +++ b/benchmark/predict_1x1x0.cpp @@ -48,9 +48,7 @@ namespace fcarouge::benchmark { namespace { //! @benchmark Measure predict, empty benchmark performance. void bench(::benchmark::State &benchmark_state) { - using kalman = kalman; - - kalman filter; + kalman filter{state{0.F}, output}; for (auto _ : benchmark_state) { ::benchmark::ClobberMemory(); diff --git a/benchmark/predict_1x1x1.cpp b/benchmark/predict_1x1x1.cpp index 02635f7a81..43bb7c4cd6 100644 --- a/benchmark/predict_1x1x1.cpp +++ b/benchmark/predict_1x1x1.cpp @@ -49,15 +49,14 @@ namespace fcarouge::benchmark { namespace { //! @benchmark Measure predict, empty benchmark performance. void bench(::benchmark::State &benchmark_state) { - using kalman = kalman; - - kalman filter; + kalman filter{state{0.F}, output, input}; std::random_device random_device; std::mt19937 random_generator{random_device()}; std::uniform_real_distribution uniformly_distributed; for (auto _ : benchmark_state) { - const typename kalman::output u{uniformly_distributed(random_generator)}; + const typename decltype(filter)::output u{ + uniformly_distributed(random_generator)}; ::benchmark::ClobberMemory(); const auto start{clock::now()}; diff --git a/benchmark/predict_linalg_x1x.cpp b/benchmark/predict_linalg_x1x.cpp index 72bfbd6612..0ca0b9eeb6 100644 --- a/benchmark/predict_linalg_x1x.cpp +++ b/benchmark/predict_linalg_x1x.cpp @@ -59,9 +59,8 @@ template using vector = column_vector; //! states and inputs with the Eigen linear algebra backend. template void bench(::benchmark::State &benchmark_state) { - using kalman = kalman, float, vector>; - - kalman filter; + kalman filter{state{vector{}}, output, + input>}; std::random_device random_device; std::mt19937 random_generator{random_device()}; std::uniform_real_distribution uniformly_distributed; @@ -74,7 +73,7 @@ void bench(::benchmark::State &benchmark_state) { uv[position] = uniformly_distributed(random_generator); }); - typename kalman::input u{uv}; + const typename decltype(filter)::input u{uv}; ::benchmark::ClobberMemory(); const auto start{clock::now()}; diff --git a/benchmark/update_1x1x0.cpp b/benchmark/update_1x1x0.cpp index 96fbe908df..0920f5c533 100644 --- a/benchmark/update_1x1x0.cpp +++ b/benchmark/update_1x1x0.cpp @@ -49,15 +49,14 @@ namespace fcarouge::benchmark { namespace { //! @benchmark Measure update, empty benchmark performance. void bench(::benchmark::State &benchmark_state) { - using kalman = kalman; - kalman filter; std::random_device random_device; std::mt19937 random_generator{random_device()}; std::uniform_real_distribution uniformly_distributed; for (auto _ : benchmark_state) { - const typename kalman::output z{uniformly_distributed(random_generator)}; + const typename decltype(filter)::output z{ + uniformly_distributed(random_generator)}; ::benchmark::ClobberMemory(); const auto start{clock::now()}; diff --git a/benchmark/update_1x1x1.cpp b/benchmark/update_1x1x1.cpp index 776113cd8a..67bc7d0a7f 100644 --- a/benchmark/update_1x1x1.cpp +++ b/benchmark/update_1x1x1.cpp @@ -49,15 +49,14 @@ namespace fcarouge::benchmark { namespace { //! @benchmark Measure update, empty benchmark performance. void bench(::benchmark::State &benchmark_state) { - using kalman = kalman; - - kalman filter; + kalman filter{state{0.F}, output, input}; std::random_device random_device; std::mt19937 random_generator{random_device()}; std::uniform_real_distribution uniformly_distributed; for (auto _ : benchmark_state) { - const typename kalman::output z{uniformly_distributed(random_generator)}; + const typename decltype(filter)::output z{ + uniformly_distributed(random_generator)}; ::benchmark::ClobberMemory(); const auto start{clock::now()}; diff --git a/benchmark/update_linalg_xx0.cpp b/benchmark/update_linalg_xx0.cpp index 172ea89868..e53d52ca61 100644 --- a/benchmark/update_linalg_xx0.cpp +++ b/benchmark/update_linalg_xx0.cpp @@ -68,9 +68,7 @@ template using vector = column_vector; //! states and outputs with the Eigen linear algebra backend. template void bench(::benchmark::State &benchmark_state) { - using kalman = kalman, vector, void>; - - kalman filter; + kalman filter{state{vector{}}, output>}; std::random_device random_device; std::mt19937 random_generator{random_device()}; std::uniform_real_distribution uniformly_distributed; @@ -83,7 +81,7 @@ void bench(::benchmark::State &benchmark_state) { zv[position] = uniformly_distributed(random_generator); }); - typename kalman::output z{zv}; + const typename decltype(filter)::output z{zv}; ::benchmark::ClobberMemory(); const auto start{clock::now()};