diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-06 15:29:39 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-06 15:29:39 +0200 |
commit | 8a509ad4c5e15fbf7eaade1c8bf4834f0d0069c5 (patch) | |
tree | fcff727adbea0ece771efbfdab54fc4e6c8289e4 /src/example | |
parent | aa8755148cbca29b584f7a146636b506070717f9 (diff) |
`make format`
Diffstat (limited to 'src/example')
-rw-r--r-- | src/example/components_internal.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/example/components_internal.cpp b/src/example/components_internal.cpp index 4246dd7..54ce295 100644 --- a/src/example/components_internal.cpp +++ b/src/example/components_internal.cpp @@ -6,13 +6,13 @@ #include <cassert> #include <chrono> -#include <crepe/util/log.h> +#include <crepe/Collider.h> +#include <crepe/Component.h> #include <crepe/ComponentManager.h> #include <crepe/GameObject.h> -#include <crepe/Component.h> -#include <crepe/Sprite.h> #include <crepe/Rigidbody.h> -#include <crepe/Collider.h> +#include <crepe/Sprite.h> +#include <crepe/util/log.h> using namespace crepe; using namespace std; @@ -24,36 +24,37 @@ int main() { auto & mgr = ComponentManager::get_instance(); - auto start_adding = chrono::high_resolution_clock::now(); + auto start_adding = chrono::high_resolution_clock::now(); - GameObject * game_object[OBJ_COUNT]; + GameObject * game_object[OBJ_COUNT]; - for (int i = 0; i < OBJ_COUNT; ++i) { - game_object[i] = new GameObject(i, "Name", "Tag", 0); + for (int i = 0; i < OBJ_COUNT; ++i) { + game_object[i] = new GameObject(i, "Name", "Tag", 0); - game_object[i]->add_component<Sprite>("test"); - game_object[i]->add_component<Rigidbody>(0, 0, i); - game_object[i]->add_component<Collider>(i); - } + game_object[i]->add_component<Sprite>("test"); + game_object[i]->add_component<Rigidbody>(0, 0, i); + game_object[i]->add_component<Collider>(i); + } - auto stop_adding = chrono::high_resolution_clock::now(); + auto stop_adding = chrono::high_resolution_clock::now(); - auto sprites = mgr.get_components_by_type<Sprite>(); - for (auto sprite : sprites) { + auto sprites = mgr.get_components_by_type<Sprite>(); + for (auto sprite : sprites) { assert(sprite.get().path == "test"); - } + } - auto stop_looping = chrono::high_resolution_clock::now(); + auto stop_looping = chrono::high_resolution_clock::now(); - for (int i = 0; i < OBJ_COUNT; ++i) { - delete game_object[i]; - } + for (int i = 0; i < OBJ_COUNT; ++i) { + delete game_object[i]; + } - auto add_time = chrono::duration_cast<chrono::microseconds>(stop_adding - start_adding); - auto loop_time = chrono::duration_cast<chrono::microseconds>(stop_looping - stop_adding); + auto add_time = chrono::duration_cast<chrono::microseconds>(stop_adding + - start_adding); + auto loop_time = chrono::duration_cast<chrono::microseconds>(stop_looping + - stop_adding); printf("add time: %ldus\n", add_time.count()); printf("loop time: %ldus\n", loop_time.count()); return 0; } - |