Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[benchmark] enable benchmark when Google fixed #498

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 3 additions & 4 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;
kalman filter{state{0.F}, output<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
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
Loading