aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-11-23 22:16:45 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-11-23 22:16:45 +0100
commit86b1f2208214fdb207e7d0541a293625990016c4 (patch)
treee4c18db084a6ab52d8a682ce2741be65c78e50ab
parentc341f6a44699d71b8b20e6b814274b30e43514c8 (diff)
Added simple profling test
-rw-r--r--src/test/Profiling.cpp48
1 files 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<CollisionEvent>([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<float>(game_object_count*2),0});
+ gameobject.add_component<Rigidbody>(Rigidbody::Data{
+ .body_type = Rigidbody::BodyType::STATIC,
+ .use_gravity = false,
+ });
+ gameobject.add_component<BoxCollider>(vec2{0, 0}, 1, 1);
+ gameobject.add_component<BehaviorScript>().set_script<TestScript>();
+ Color color(0, 0, 0, 0);
+ gameobject.add_component<Sprite>(
+ make_shared<Texture>("/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;
}