From 86b1f2208214fdb207e7d0541a293625990016c4 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Sat, 23 Nov 2024 22:16:45 +0100 Subject: Added simple profling test --- src/test/Profiling.cpp | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index 9929288..518d1c5 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -25,22 +25,14 @@ using namespace std::chrono_literals; using namespace crepe; using namespace testing; -class CollisionHandler : public Script { -public: - int box_id; - - CollisionHandler(int box_id) { - this->box_id = box_id; - } - - bool on_collision(const CollisionEvent& ev) { - // test load? +class TestScript : public Script { + bool oncollision(const CollisionEvent& test) { + Log::logf("Box {} script on_collision()", test.info.first.collider.game_object_id); return true; } - void init() { subscribe([this](const CollisionEvent& ev) -> bool { - return this->on_collision(ev); + return this->oncollision(ev); }); } void update() { @@ -115,11 +107,41 @@ TEST_F(Profiling, Profiling_example) { int game_object_count = 0; long long total_time = 0; while (total_time < 16000) { - game_object_count++; + { //define gameobject used for testing GameObject gameobject = mgr.new_object("gameobject","",{0,0}); } + + game_object_count++; + total_time = run_all_systems(); + if(game_object_count >= max_gameobject_count) break; + } + log_timings(total_time,game_object_count); + EXPECT_GE(game_object_count, min_gameobject_count); +} + +TEST_F(Profiling, Profiling_small_object_no_collision) { + int game_object_count = 0; + long long total_time = 0; + while (total_time < 16000) { + + { + //define gameobject used for testing + GameObject gameobject = mgr.new_object("gameobject","",{static_cast(game_object_count*2),0}); + gameobject.add_component(Rigidbody::Data{ + .body_type = Rigidbody::BodyType::STATIC, + .use_gravity = false, + }); + gameobject.add_component(vec2{0, 0}, 1, 1); + gameobject.add_component().set_script(); + Color color(0, 0, 0, 0); + gameobject.add_component( + make_shared("/home/jaro/crepe/asset/texture/green_square.png"), color, + FlipSettings{true, true}); + } + render_sys.update(); + game_object_count++; total_time = run_all_systems(); if(game_object_count >= max_gameobject_count) break; } -- cgit v1.2.3