exp-ecs icon indicating copy to clipboard operation
exp-ecs copied to clipboard

Comparison with other ECS frameworks

Open Misiur opened this issue 6 years ago • 6 comments

Hi, did you run any benchmarks against ECX or Edge (specifically this branch)?

Misiur avatar Sep 22 '18 22:09 Misiur

I just had a look on it. Looks like it is only benchmarking one thing: iterate all entities and perform some task on their components.

On my macbook running the ecx framework I got around 60000 op/s. ash = 4000 op/s

My current ecs implementation has around 8000 op/s, which is expected

Though after some optimization I got 130000 op/s.

Maybe we should benchmark other aspect as well.

kevinresol avatar Sep 23 '18 08:09 kevinresol

So it's >2x faster than ECX? (i.e is 130k not a typo instead of 13k)

Misiur avatar Sep 23 '18 18:09 Misiur

Yes, 2x as fast Though I can barely test on nodejs because the benchmark framework seems broken

kevinresol avatar Sep 24 '18 02:09 kevinresol

Did your optimisations make it in? Looks like you are still iterating on maps in places. I would typically create a separate array of iteration (potentially making a new class implementing a map interface). I think the HashTable in polygonal.ds lazy inits an array to use for the iterator.

JoeCreates avatar Nov 11 '18 16:11 JoeCreates

It is iterating an array now: https://github.com/kevinresol/ecs/blob/9ad36a0/src/ecs/node/NodeList.hx#L72

But I need to re-emphasize that the optimizing on a single part of the codebase doesn't mean much. While iteration is faster, add/remove entity/component may have become slower.

kevinresol avatar Nov 15 '18 03:11 kevinresol

Oh... you removed the map? To be clear I didn't mean to suggest to replace maps with arrays, but rather to use both. Use array (or perhaps list) for iteration and map for addressing by component type. The overhead of maintaining two structures is negligible compared to the cost of using one or the other for purposes to which they are not suited.

Polygonal's HashTable does this and also allows for reuse of the iterator which could further help (where code is synchronous). (https://github.com/polygonal/ds/blob/master/src/polygonal/ds/HashTable.hx)

JoeCreates avatar Nov 16 '18 07:11 JoeCreates