Crafty Blog - JavaScript Game Engine Development

Development of Crafty

0 notes &

Optimization for 0.3

Previously in v0.2.1, whenever a value is changed on a 2D entity, it would automatically redraw itself even if the next line is another modification. This means it is drawing itself twice when only once is sufficient. This has been fixed and has given some great performance gains.

Another optimization was in the Crafty selector where multiple calls to the Crafty constructor was used which was unnecessary and where .has() was used, directly accessing the component collection meant less function calls. You can see the changes on Github.

I used JSLitmus to benchmark the differences between the working version 0.3 and the latest release 0.2.1. Here are the results (bigger bar is better):

This test created two entities with the different versions of Crafty and modified the x position and then the x and y. v0.3 wins every test.

This test shows the results of selecting entities by components using the selector engine. Again 0.3 wins every test.

The tests show a significant improvement and I hope to find more areas to optimize.