diff --git a/TODO b/TODO index ad9631f94..fd8f7326d 100644 --- a/TODO +++ b/TODO @@ -20,4 +20,3 @@ - each components only return actual component, so shared components are returned only once * add a sort of "fast each" for when users know they are not to add/remove components, it can use directly raw access and improve even further performance * types defined at runtime that refer to the same compile-time type (but to different pools) are possible, the library is almost there -* view/group iterators that return entities and components? I'd still like to have it :-) diff --git a/test/benchmark/benchmark.cpp b/test/benchmark/benchmark.cpp index cc0f87531..a8462defc 100644 --- a/test/benchmark/benchmark.cpp +++ b/test/benchmark/benchmark.cpp @@ -58,7 +58,6 @@ void pathological(Func func) { } } - func(registry, [](const auto &...) {}); func(registry, [](auto &... comp) { ((comp.x = {}), ...); }); @@ -152,7 +151,6 @@ TEST(Benchmark, IterateSingleComponent1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -177,7 +175,6 @@ TEST(Benchmark, IterateSingleComponentRuntime1M) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; }); @@ -200,35 +197,6 @@ TEST(Benchmark, IterateTwoComponents1M) { timer.elapsed(); }; - test([](const auto &...) {}); - test([](auto &... comp) { - ((comp.x = {}), ...); - }); -} - -TEST(Benchmark, IterateTwoComponentsRangeBasedFor1M) { - entt::registry registry; - - std::cout << "Iterating over 1000000 entities, two components (range-based for)" << std::endl; - - for(std::uint64_t i = 0; i < 1000000L; i++) { - const auto entity = registry.create(); - registry.assign(entity); - registry.assign(entity); - } - - auto test = [®istry](auto func) { - auto view = registry.view(); - timer timer; - - for(const auto entity: registry.view()) { - func(view.get(entity), view.get(entity)); - } - - timer.elapsed(); - }; - - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -254,7 +222,6 @@ TEST(Benchmark, IterateTwoComponents1MHalf) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -280,7 +247,6 @@ TEST(Benchmark, IterateTwoComponents1MOne) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -304,7 +270,6 @@ TEST(Benchmark, IterateTwoComponentsNonOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -328,7 +293,6 @@ TEST(Benchmark, IterateTwoComponentsFullOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -352,7 +316,6 @@ TEST(Benchmark, IterateTwoComponentsPartialOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -378,7 +341,6 @@ TEST(Benchmark, IterateTwoComponentsRuntime1M) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; registry.get(entity).x = {}; @@ -408,7 +370,6 @@ TEST(Benchmark, IterateTwoComponentsRuntime1MHalf) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; registry.get(entity).x = {}; @@ -438,7 +399,6 @@ TEST(Benchmark, IterateTwoComponentsRuntime1MOne) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; registry.get(entity).x = {}; @@ -463,36 +423,6 @@ TEST(Benchmark, IterateThreeComponents1M) { timer.elapsed(); }; - test([](const auto &...) {}); - test([](auto &... comp) { - ((comp.x = {}), ...); - }); -} - -TEST(Benchmark, IterateThreeComponentsRangeBasedFor1M) { - entt::registry registry; - - std::cout << "Iterating over 1000000 entities, three components (range-based for)" << std::endl; - - for(std::uint64_t i = 0; i < 1000000L; i++) { - const auto entity = registry.create(); - registry.assign(entity); - registry.assign(entity); - registry.assign>(entity); - } - - auto test = [®istry](auto func) { - auto view = registry.view>(); - timer timer; - - for(const auto entity: view) { - func(view.get(entity), view.get(entity), view.get>(entity)); - } - - timer.elapsed(); - }; - - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -519,7 +449,6 @@ TEST(Benchmark, IterateThreeComponents1MHalf) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -546,7 +475,6 @@ TEST(Benchmark, IterateThreeComponents1MOne) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -571,7 +499,6 @@ TEST(Benchmark, IterateThreeComponentsNonOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -596,7 +523,6 @@ TEST(Benchmark, IterateThreeComponentsFullOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -621,7 +547,6 @@ TEST(Benchmark, IterateThreeComponentsPartialOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -648,7 +573,6 @@ TEST(Benchmark, IterateThreeComponentsRuntime1M) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; registry.get(entity).x = {}; @@ -680,7 +604,6 @@ TEST(Benchmark, IterateThreeComponentsRuntime1MHalf) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; registry.get(entity).x = {}; @@ -712,7 +635,6 @@ TEST(Benchmark, IterateThreeComponentsRuntime1MOne) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; registry.get(entity).x = {}; @@ -740,42 +662,6 @@ TEST(Benchmark, IterateFiveComponents1M) { timer.elapsed(); }; - test([](const auto &...) {}); - test([](auto &... comp) { - ((comp.x = {}), ...); - }); -} - -TEST(Benchmark, IterateFiveComponentsRangeBasedFor1M) { - entt::registry registry; - - std::cout << "Iterating over 1000000 entities, five components (range-based for)" << std::endl; - - for(std::uint64_t i = 0; i < 1000000L; i++) { - const auto entity = registry.create(); - registry.assign(entity); - registry.assign(entity); - registry.assign>(entity); - registry.assign>(entity); - registry.assign>(entity); - } - - auto test = [®istry](auto func) { - auto view = registry.view, comp<1>, comp<2>>(); - timer timer; - - for(const auto entity: view) { - func(view.get(entity), - view.get(entity), - view.get>(entity), - view.get>(entity), - view.get>(entity)); - } - - timer.elapsed(); - }; - - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -804,7 +690,6 @@ TEST(Benchmark, IterateFiveComponents1MHalf) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -833,7 +718,6 @@ TEST(Benchmark, IterateFiveComponents1MOne) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -860,7 +744,6 @@ TEST(Benchmark, IterateFiveComponentsNonOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -887,7 +770,6 @@ TEST(Benchmark, IterateFiveComponentsFullOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -914,7 +796,6 @@ TEST(Benchmark, IterateFiveComponentsPartialFourOfFiveOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -941,7 +822,6 @@ TEST(Benchmark, IterateFiveComponentsPartialThreeOfFiveOwningGroup1M) { timer.elapsed(); }; - test([](const auto &...) {}); test([](auto &... comp) { ((comp.x = {}), ...); }); @@ -976,7 +856,6 @@ TEST(Benchmark, IterateFiveComponentsRuntime1M) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; registry.get(entity).x = {}; @@ -1018,7 +897,6 @@ TEST(Benchmark, IterateFiveComponentsRuntime1MHalf) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; registry.get(entity).x = {}; @@ -1060,7 +938,6 @@ TEST(Benchmark, IterateFiveComponentsRuntime1MOne) { timer.elapsed(); }; - test([](auto) {}); test([®istry](auto entity) { registry.get(entity).x = {}; registry.get(entity).x = {}; @@ -1080,23 +957,6 @@ TEST(Benchmark, IteratePathological) { }); } -TEST(Benchmark, IteratePathologicalRangeBasedFor) { - std::cout << "Pathological case (range-based for)" << std::endl; - - pathological([](auto ®istry, auto func) { - auto view = registry.template view>(); - timer timer; - - for(const auto entity: view) { - func(view.template get(entity), - view.template get(entity), - view.template get>(entity)); - } - - timer.elapsed(); - }); -} - TEST(Benchmark, IteratePathologicalNonOwningGroup) { std::cout << "Pathological case (non-owning group)" << std::endl;