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:
setuptells it to do;fntells it to do and measures how long they took.Notice this one
setup- manyfnorganization.Now lets quickly looks through the code for
kill. Once you doentity.kill, it gets intoworld._removedqueue. This queue is processed when you doloopStartand all entities are actually killed via_removeEntity._removeEntitysets entity's_alivetofalseand does nothing for non-live entities.This means that in your third benchmark in
killcase only the first execution offnbody in a sample does any heavy work because on all subsequent executions entities are already killed.Hence the speed increase.