Tests are located here:
- https://github.com/ooflorent/makrjs/blob/perf-internal/benchmark/internal-1.js
- https://github.com/ooflorent/makrjs/blob/perf-internal/benchmark/internal-2.js
- https://github.com/ooflorent/makrjs/blob/perf-internal/benchmark/internal-3.js
Execute the following command to run the test suite:
grunt benchmark:internal
Well I have no idea what makr is or what it does, so everything below comes from just quickly reading through the code.
Lets recall how harness runs benchmarks:
setup
tells it to do;fn
tells it to do and measures how long they took.Notice this one
setup
- manyfn
organization.Now lets quickly looks through the code for
kill
. Once you doentity.kill
, it gets intoworld._removed
queue. This queue is processed when you doloopStart
and all entities are actually killed via_removeEntity
._removeEntity
sets entity's_alive
tofalse
and does nothing for non-live entities.This means that in your third benchmark in
kill
case only the first execution offn
body in a sample does any heavy work because on all subsequent executions entities are already killed.Hence the speed increase.