slightly improved

This commit is contained in:
Michele Caini
2018-02-12 19:22:32 +01:00
parent 59cec88a28
commit a19ef9bd16
3 changed files with 20 additions and 22 deletions

View File

@@ -155,19 +155,19 @@ Dell XPS 13 out of the mid 2014):
| Benchmark | EntityX (compile-time) | EnTT |
|-----------|-------------|-------------|
| Create 10M entities | 0.1289s | **0.0409s** |
| Destroy 10M entities | **0.0531s** | 0.0546s |
| Standard view, 10M entities, one component | 0.0107s | **1.6e-07s** |
| Standard view, 10M entities, two components | **0.0113s** | 0.0295s |
| Standard view, 10M entities, two components<br/>Half of the entities have all the components | **0.0078s** | 0.0150s |
| Standard view, 10M entities, two components<br/>One of the entities has all the components | 0.0071s | **8.8e-07s** |
| Persistent view, 10M entities, two components | 0.0113s | **5.7e-07s** |
| Standard view, 10M entities, five components | **0.0091s** | 0.0688s |
| Persistent view, 10M entities, five components | 0.0091s | **2.9e-07s** |
| Standard view, 10M entities, ten components | **0.0105s** | 0.1403s |
| Standard view, 10M entities, ten components<br/>Half of the entities have all the components | **0.0090s** | 0.0620s |
| Create 10M entities | 0.1289s | **0.0388s** |
| Destroy 10M entities | **0.0531s** | 0.0828s |
| Standard view, 10M entities, one component | 0.0107s | **7.8e-08s** |
| Standard view, 10M entities, two components | **0.0113s** | 0.0244s |
| Standard view, 10M entities, two components<br/>Half of the entities have all the components | **0.0078s** | 0.0129s |
| Standard view, 10M entities, two components<br/>One of the entities has all the components | 0.0071s | **5.5e-07s** |
| Persistent view, 10M entities, two components | 0.0113s | **1.1e-07s** |
| Standard view, 10M entities, five components | **0.0091s** | 0.0672s |
| Persistent view, 10M entities, five components | 0.0091s | **2.5e-07s** |
| Standard view, 10M entities, ten components | **0.0105s** | 0.1306s |
| Standard view, 10M entities, ten components<br/>Half of the entities have all the components | **0.0090s** | 0.0629s |
| Standard view, 10M entities, ten components<br/>One of the entities has all the components | 0.0070s | **1.3e-06s** |
| Persistent view, 10M entities, ten components | 0.0105s | **6.2e-07s** |
| Persistent view, 10M entities, ten components | 0.0105s | **5.0e-07s** |
| Sort 150k entities, one component<br/>Arrays are in reverse order | - | **0.0043s** |
| Sort 150k entities, enforce permutation<br/>Arrays are in reverse order | - | **0.0006s** |

View File

@@ -59,7 +59,7 @@ class SparseSet<Entity> {
struct Iterator final {
using value_type = Entity;
Iterator(const std::vector<value_type> *direct, std::size_t pos)
Iterator(const std::vector<value_type> &direct, std::size_t pos)
: direct{direct}, pos{pos}
{}
@@ -73,7 +73,7 @@ class SparseSet<Entity> {
}
bool operator==(const Iterator &other) const noexcept {
return other.pos == pos && other.direct == direct;
return other.pos == pos;
}
bool operator!=(const Iterator &other) const noexcept {
@@ -81,11 +81,11 @@ class SparseSet<Entity> {
}
value_type operator*() const noexcept {
return (*direct)[pos-1];
return direct[pos-1];
}
private:
const std::vector<value_type> *direct;
const std::vector<value_type> &direct;
std::size_t pos;
};
@@ -184,7 +184,7 @@ public:
* @return An iterator to the first element of the internal packed array.
*/
iterator_type begin() const noexcept {
return Iterator{&direct, direct.size()};
return Iterator{direct, direct.size()};
}
/**
@@ -201,7 +201,7 @@ public:
* internal packed array.
*/
iterator_type end() const noexcept {
return Iterator{&direct, 0};
return Iterator{direct, 0};
}
/**

View File

@@ -358,7 +358,7 @@ class View final {
class Iterator {
inline bool valid() const noexcept {
using accumulator_type = bool[];
auto entity = *begin;
const auto entity = *begin;
bool all = true;
accumulator_type accumulator = { all, (all = all && std::get<pool_type<Component> &>(pools).has(entity))... };
(void)accumulator;
@@ -377,9 +377,7 @@ class View final {
}
Iterator & operator++() noexcept {
++begin;
while(begin != end && !valid()) { ++begin; }
return *this;
return (++begin != end && !valid()) ? ++(*this) : *this;
}
Iterator operator++(int) noexcept {