From 2bb0c82c30f792d97c54eecba9211db02e737dbd Mon Sep 17 00:00:00 2001 From: Orange Date: Mon, 22 Sep 2025 02:29:36 +0300 Subject: [PATCH] added source engine benchmark --- benchmark/benchmark_mat.cpp | 9 ++++----- benchmark/benchmark_projectile_pred.cpp | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/benchmark/benchmark_mat.cpp b/benchmark/benchmark_mat.cpp index f2eda9a..2e54382 100644 --- a/benchmark/benchmark_mat.cpp +++ b/benchmark/benchmark_mat.cpp @@ -4,7 +4,6 @@ #include #include -#include using namespace omath; @@ -17,7 +16,7 @@ void mat_float_multiplication_col_major(benchmark::State& state) b.set(7.f); - for (auto _ : state) + for ([[maybe_unused]] const auto _ : state) std::ignore = a * b; } void mat_float_multiplication_row_major(benchmark::State& state) @@ -29,7 +28,7 @@ void mat_float_multiplication_row_major(benchmark::State& state) b.set(7.f); - for (auto _ : state) + for ([[maybe_unused]] const auto _ : state) std::ignore = a * b; } @@ -42,7 +41,7 @@ void mat_double_multiplication_row_major(benchmark::State& state) b.set(7.f); - for (auto _ : state) + for ([[maybe_unused]] const auto _ : state) std::ignore = a * b; } @@ -55,7 +54,7 @@ void mat_double_multiplication_col_major(benchmark::State& state) b.set(7.f); - for (auto _ : state) + for ([[maybe_unused]] const auto _ : state) std::ignore = a * b; } diff --git a/benchmark/benchmark_projectile_pred.cpp b/benchmark/benchmark_projectile_pred.cpp index 5cbfb35..a633754 100644 --- a/benchmark/benchmark_projectile_pred.cpp +++ b/benchmark/benchmark_projectile_pred.cpp @@ -1,3 +1,23 @@ // // Created by Vlad on 9/18/2025. // +#include +#include +using namespace omath; + +using namespace omath::projectile_prediction; + +constexpr float simulation_time_step = 1.f / 1000.f; +constexpr float hit_distance_tolerance = 5.f; + +void source_engine_projectile_prediction(benchmark::State& state) +{ + constexpr Target target{.m_origin = {100, 0, 90}, .m_velocity = {0, 0, 0}, .m_is_airborne = false}; + constexpr Projectile projectile = {.m_origin = {3, 2, 1}, .m_launch_speed = 5000, .m_gravity_scale = 0.4}; + + for ([[maybe_unused]] const auto _: state) + std::ignore = ProjPredEngineLegacy(400, simulation_time_step, 50, hit_distance_tolerance) + .maybe_calculate_aim_point(projectile, target); +} + +BENCHMARK(source_engine_projectile_prediction)->Iterations(10'000); \ No newline at end of file