#include #include #include "systems/physics_system.hpp" #include "entities/solid_box.hpp" // Does my physics update scale linearly or quadratically with object count? namespace Nimbin { static void BM_PhysicsUpdateObjects(benchmark::State& state) { const size_t N = static_cast(state.range(0)); std::vector> owners; std::vector objects; owners.reserve(N); objects.reserve(N); for (size_t i = 0; i < N; ++i) { double x = static_cast(i % 10) * 2.5; double z = static_cast(i / 10) * 2.5; auto box = cpputils::make_unique(Vec3{x, 0.0, z}, Vec3{0.5, 0.5, 0.5}); box->body.mode = PhysicsMode::Dynamic; box->body.vel = { 0.1, 0.0, 0.0 }; objects.push_back(box.get()); owners.push_back(std::move(box)); } PhysicsSystem sys; constexpr double dt = 1.0 / 60.0; for (auto _ : state) { sys.update_Objects(objects, dt, 25.0); } state.SetLabel("N=" + std::to_string(N)); } BENCHMARK(BM_PhysicsUpdateObjects)->Arg(10)->Arg(50)->Arg(100)->Arg(200); } // namespace Nimbin