/** \file * * Standalone example for usage of the internal ECS */ #include #include #include #include #include #include #include #include #include using namespace crepe::api; using namespace crepe; using namespace std; #define OBJ_COUNT 100000 int main() { dbg_trace(); auto & mgr = ComponentManager::get_instance(); auto start_adding = chrono::high_resolution_clock::now(); GameObject * game_object[OBJ_COUNT]; for (int i = 0; i < OBJ_COUNT; ++i) { game_object[i] = new GameObject(i, "Name", "Tag", 0); game_object[i]->add_component("test"); game_object[i]->add_component(0, 0, i); game_object[i]->add_component(i); } auto stop_adding = chrono::high_resolution_clock::now(); auto sprites = mgr.get_components_by_type(); for (auto sprite : sprites) { assert(sprite.get().path == "test"); } auto stop_looping = chrono::high_resolution_clock::now(); for (int i = 0; i < OBJ_COUNT; ++i) { delete game_object[i]; } auto add_time = chrono::duration_cast(stop_adding - start_adding); auto loop_time = chrono::duration_cast(stop_looping - stop_adding); printf("add time: %ldus\n", add_time.count()); printf("loop time: %ldus\n", loop_time.count()); return 0; }