};
+struct Direction : public Component<Direction> {
+};
+
+
struct BenchmarkFixture {
BenchmarkFixture() : em(ev) {}
cout << "iterating over " << count << " entities, unpacking one component" << endl;
ComponentHandle<Position> position;
- for (auto e : em.entities_with_components<Position>(position)) {
+ for (auto e : em.entities_with_components(position)) {
+ (void)e;
+ }
+}
+
+TEST_CASE_METHOD(BenchmarkFixture, "TestEntityIterationUnpackTwo") {
+ int count = 10000000;
+ for (int i = 0; i < count; i++) {
+ auto e = em.create();
+ e.assign<Position>();
+ e.assign<Direction>();
+ }
+
+ AutoTimer t;
+ cout << "iterating over " << count << " entities, unpacking two components" << endl;
+
+ ComponentHandle<Position> position;
+ ComponentHandle<Direction> direction;
+ for (auto e : em.entities_with_components(position, direction)) {
(void)e;
- position.valid();
}
}