Skip to content

Commit

Permalink
[benchmark] enable benchmark when Google fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisCarouge committed Sep 29, 2024
1 parent 11dba0b commit 61ef5e8
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 54 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ include(CPack)
include(CTest)
include(GNUInstallDirs)

add_subdirectory("benchmark")
add_subdirectory("cmake")
add_subdirectory("include")
add_subdirectory("linalg")
Expand Down
32 changes: 0 additions & 32 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
$<TARGET_FILE:kalman_benchmark_update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0_driver>
"--benchmark_out=update_${BACKEND}_${STATE_SIZE}x${OUTPUT_SIZE}x0.json"
)
endforeach()
endforeach()
endforeach()
4 changes: 1 addition & 3 deletions benchmark/predict_1x1x0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ namespace fcarouge::benchmark {
namespace {
//! @benchmark Measure predict, empty benchmark performance.
void bench(::benchmark::State &benchmark_state) {
using kalman = kalman<float, float>;

kalman filter;
kalman filter{state{0.F}, output<float>};

for (auto _ : benchmark_state) {
::benchmark::ClobberMemory();
Expand Down
7 changes: 3 additions & 4 deletions benchmark/predict_1x1x1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ namespace fcarouge::benchmark {
namespace {
//! @benchmark Measure predict, empty benchmark performance.
void bench(::benchmark::State &benchmark_state) {
using kalman = kalman<float, float, float>;

kalman filter;
kalman filter{state{0.F}, output<float>, input<float>};
std::random_device random_device;
std::mt19937 random_generator{random_device()};
std::uniform_real_distribution<float> 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()};
Expand Down
7 changes: 3 additions & 4 deletions benchmark/predict_linalg_x1x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ template <auto Size> using vector = column_vector<float, Size>;
//! states and inputs with the Eigen linear algebra backend.
template <auto StateSize, auto InputSize>
void bench(::benchmark::State &benchmark_state) {
using kalman = kalman<vector<StateSize>, float, vector<InputSize>>;

kalman filter;
kalman filter{state{vector<StateSize>{}}, output<float>,
input<vector<InputSize>>};
std::random_device random_device;
std::mt19937 random_generator{random_device()};
std::uniform_real_distribution<float> uniformly_distributed;
Expand All @@ -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()};
Expand Down
5 changes: 2 additions & 3 deletions benchmark/update_1x1x0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ namespace fcarouge::benchmark {
namespace {
//! @benchmark Measure update, empty benchmark performance.
void bench(::benchmark::State &benchmark_state) {
using kalman = kalman<float, float>;

kalman filter;
std::random_device random_device;
std::mt19937 random_generator{random_device()};
std::uniform_real_distribution<float> 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()};
Expand Down
7 changes: 3 additions & 4 deletions benchmark/update_1x1x1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ namespace fcarouge::benchmark {
namespace {
//! @benchmark Measure update, empty benchmark performance.
void bench(::benchmark::State &benchmark_state) {
using kalman = kalman<float, float, float>;

kalman filter;
kalman filter{state{0.F}, output<float>, input<float>};
std::random_device random_device;
std::mt19937 random_generator{random_device()};
std::uniform_real_distribution<float> 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()};
Expand Down
6 changes: 2 additions & 4 deletions benchmark/update_linalg_xx0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ template <auto Size> using vector = column_vector<float, Size>;
//! states and outputs with the Eigen linear algebra backend.
template <auto StateSize, auto OutputSize>
void bench(::benchmark::State &benchmark_state) {
using kalman = kalman<vector<StateSize>, vector<OutputSize>, void>;

kalman filter;
kalman filter{state{vector<StateSize>{}}, output<vector<OutputSize>>};
std::random_device random_device;
std::mt19937 random_generator{random_device()};
std::uniform_real_distribution<float> uniformly_distributed;
Expand All @@ -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()};
Expand Down

0 comments on commit 61ef5e8

Please sign in to comment.