#include #include #include "systems/word_ai_system.hpp" #include "systems/carry_system.hpp" #include "entities/player.hpp" #include "text/token.hpp" namespace Nimbin { // What's the per-frame cost of my AI system, and does it scale with the number of words? static void BM_WordAiUpdate(benchmark::State& state) { const size_t N = static_cast(state.range(0)); Player player; player.pos = { 0.0, 0.0, 0.0 }; CarriedLine carried; DynArray words; words.reserve(N); for (size_t i = 0; i < N; ++i) { double angle = (static_cast(i) / N) * 6.28318; Vec3 pos { 5.0 * SDL_cos(angle), 0.0, 5.0 * SDL_sin(angle) }; words.push_back(Text::make_Token("hover", Text::Token::depth_floor, 0.003f, pos)); } WordAiSystem ai; DynArray dropped; constexpr double dt = 1.0 / 60.0; for (auto _ : state) { dropped.clear(); ai.update(words, player, carried, dropped, dt); } state.SetLabel("N=" + std::to_string(N)); } BENCHMARK(BM_WordAiUpdate)->Arg(10)->Arg(50)->Arg(100)->Arg(200); } // namespace Nimbin