kevinresol / exp-ecs

Experimental macro-powered Entity-Component-System game engine
59 stars 5 forks source link

Comparison with other ECS frameworks #1

Open Misiur opened 6 years ago

Misiur commented 6 years ago

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

kevinresol commented 6 years ago

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.

Misiur commented 6 years ago

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

kevinresol commented 6 years ago

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

JoeCreates commented 6 years ago

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.

kevinresol commented 6 years ago

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.

JoeCreates commented 6 years ago

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)