Browse Source

more tests

Michele Caini 8 years ago
parent
commit
b4d18e94da
1 changed files with 49 additions and 0 deletions
  1. 49 0
      test/benchmark.cpp

+ 49 - 0
test/benchmark.cpp

@@ -408,3 +408,52 @@ TEST(DefaultRegistry, IterateTenComponents10MOne) {
     timer.elapsed();
     registry.reset();
 }
+
+TEST(DefaultRegistry, SortSingle) {
+    using registry_type = entt::DefaultRegistry<Position>;
+
+    registry_type registry;
+    std::vector<registry_type::entity_type> entities{};
+
+    std::cout << "Sort 10000000 entities" << std::endl;
+
+    for (uint64_t i = 0; i < 10000000L; i++) {
+        auto entity = registry.create();
+        entities.push_back(entity);
+        registry.assign<Position>(entity, i, i);
+    }
+
+    Timer timer;
+
+    registry.sort<Position>([](const auto &lhs, const auto &rhs) {
+        return lhs.x < rhs.x && lhs.y < rhs.y;
+    });
+
+    timer.elapsed();
+}
+
+TEST(DefaultRegistry, SortMulti) {
+    using registry_type = entt::DefaultRegistry<Position, Velocity>;
+
+    registry_type registry;
+    std::vector<registry_type::entity_type> entities{};
+
+    std::cout << "Sort 10000000 entities" << std::endl;
+
+    for (uint64_t i = 0; i < 10000000L; i++) {
+        auto entity = registry.create();
+        entities.push_back(entity);
+        registry.assign<Position>(entity, i, i);
+        registry.assign<Velocity>(entity, i, i);
+    }
+
+    registry.sort<Position>([](const auto &lhs, const auto &rhs) {
+        return lhs.x < rhs.x && lhs.y < rhs.y;
+    });
+
+    Timer timer;
+
+    registry.sort<Velocity, Position>();
+
+    timer.elapsed();
+}