*: minor changes
This commit is contained in:
@@ -45,7 +45,9 @@ struct default_pool final: storage<Entity, Component> {
|
||||
storage<entity_type, Component>::insert(first, last, std::forward<Args>(args)...);
|
||||
|
||||
if(!construction.empty()) {
|
||||
while(first != last) { construction.publish(*(first++)); }
|
||||
for(; first != last; ++first) {
|
||||
construction.publish(*first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,12 +60,16 @@ struct default_pool final: storage<Entity, Component> {
|
||||
void erase(It first, It last) {
|
||||
if(std::distance(first, last) == std::distance(this->begin(), this->end())) {
|
||||
if(!destruction.empty()) {
|
||||
while(first != last) { destruction.publish(*(first++)); }
|
||||
for(; first != last; ++first) {
|
||||
destruction.publish(*first);
|
||||
}
|
||||
}
|
||||
|
||||
this->clear();
|
||||
} else {
|
||||
while(first != last) { this->erase(*(first++)); }
|
||||
for(; first != last; ++first) {
|
||||
this->erase(*first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -458,12 +458,12 @@ public:
|
||||
*/
|
||||
template<typename It>
|
||||
void create(It first, It last) {
|
||||
while(destroyed != null && first != last) {
|
||||
*(first++) = recycle_identifier();
|
||||
for(; destroyed != null && first != last; ++first) {
|
||||
*first = recycle_identifier();
|
||||
}
|
||||
|
||||
while(first != last) {
|
||||
*(first++) = generate_identifier();
|
||||
for(; first != last; ++first) {
|
||||
*first = generate_identifier();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,7 +541,9 @@ public:
|
||||
*/
|
||||
template<typename It>
|
||||
void destroy(It first, It last) {
|
||||
while(first != last) { destroy(*(first++)); }
|
||||
for(; first != last; ++first) {
|
||||
destroy(*first);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -408,10 +408,9 @@ public:
|
||||
auto next = static_cast<typename traits_type::entity_type>(packed.size());
|
||||
packed.insert(packed.end(), first, last);
|
||||
|
||||
while(first != last) {
|
||||
const auto entt = *(first++);
|
||||
ENTT_ASSERT(!contains(entt));
|
||||
assure(page(entt))[offset(entt)] = entity_type{next++};
|
||||
for(; first != last; ++first) {
|
||||
ENTT_ASSERT(!contains(*first));
|
||||
assure(page(*first))[offset(*first)] = entity_type{next++};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,54 @@ TEST(Benchmark, CreateManyWithComponents) {
|
||||
timer.elapsed();
|
||||
}
|
||||
|
||||
TEST(Benchmark, Remove) {
|
||||
entt::registry registry;
|
||||
std::vector<entt::entity> entities(1000000);
|
||||
|
||||
std::cout << "Removing 1000000 components from their entities" << std::endl;
|
||||
|
||||
registry.create(entities.begin(), entities.end());
|
||||
registry.insert<int>(entities.begin(), entities.end());
|
||||
|
||||
timer timer;
|
||||
|
||||
for(auto entity: registry.view<int>()) {
|
||||
registry.remove<int>(entity);
|
||||
}
|
||||
|
||||
timer.elapsed();
|
||||
}
|
||||
|
||||
TEST(Benchmark, RemoveMany) {
|
||||
entt::registry registry;
|
||||
std::vector<entt::entity> entities(1000000);
|
||||
|
||||
std::cout << "Removing 999999 components from their entities at once" << std::endl;
|
||||
|
||||
registry.create(entities.begin(), entities.end());
|
||||
registry.insert<int>(entities.begin(), entities.end());
|
||||
|
||||
timer timer;
|
||||
auto view = registry.view<int>();
|
||||
registry.remove<int>(++view.begin(), view.end());
|
||||
timer.elapsed();
|
||||
}
|
||||
|
||||
TEST(Benchmark, RemoveAll) {
|
||||
entt::registry registry;
|
||||
std::vector<entt::entity> entities(1000000);
|
||||
|
||||
std::cout << "Removing 1000000 components from their entities at once" << std::endl;
|
||||
|
||||
registry.create(entities.begin(), entities.end());
|
||||
registry.insert<int>(entities.begin(), entities.end());
|
||||
|
||||
timer timer;
|
||||
auto view = registry.view<int>();
|
||||
registry.remove<int>(view.begin(), view.end());
|
||||
timer.elapsed();
|
||||
}
|
||||
|
||||
TEST(Benchmark, Recycle) {
|
||||
entt::registry registry;
|
||||
std::vector<entt::entity> entities(1000000);
|
||||
@@ -160,22 +208,37 @@ TEST(Benchmark, RecycleMany) {
|
||||
|
||||
TEST(Benchmark, Destroy) {
|
||||
entt::registry registry;
|
||||
std::vector<entt::entity> entities(1000000);
|
||||
|
||||
std::cout << "Destroying 1000000 entities" << std::endl;
|
||||
|
||||
for(std::uint64_t i = 0; i < 1000000L; i++) {
|
||||
registry.create();
|
||||
}
|
||||
registry.create(entities.begin(), entities.end());
|
||||
registry.insert<int>(entities.begin(), entities.end());
|
||||
|
||||
timer timer;
|
||||
|
||||
registry.each([®istry](auto entity) {
|
||||
for(auto entity: registry.view<int>()) {
|
||||
registry.destroy(entity);
|
||||
});
|
||||
}
|
||||
|
||||
timer.elapsed();
|
||||
}
|
||||
|
||||
TEST(Benchmark, DestroyMany) {
|
||||
entt::registry registry;
|
||||
std::vector<entt::entity> entities(1000000);
|
||||
|
||||
std::cout << "Destroying 1000000 entities" << std::endl;
|
||||
|
||||
registry.create(entities.begin(), entities.end());
|
||||
registry.insert<int>(entities.begin(), entities.end());
|
||||
|
||||
timer timer;
|
||||
auto view = registry.view<int>();
|
||||
registry.destroy(view.begin(), view.end());
|
||||
timer.elapsed();
|
||||
}
|
||||
|
||||
TEST(Benchmark, IterateSingleComponent1M) {
|
||||
entt::registry registry;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user