AS3 vs haXe performance

A while back I saw a documentary about fractals. I was amazed by how simple the algorithm required to generate them are, so I decided to try to make one myself using flash.

Today, all of a sudden, I got the idea to port that code to haxe, just to see if there were any noticeable difference in performance.

And yes, there’s a huge difference. In haxe, the fractal is generated in slightly less than half the time compared to AS3. And the color cycling animation I made runs almost three times as fast in haxe on my 2.66 Ghz core 2 duo MacBook. That is pretty awesome.

See for yourself:

Click here to view the AS3 fractal.

Click here to view the haXe fractal.

And if you want to peek at the source code, you can grab it here.

Tags: , , ,

4 Responses to “AS3 vs haXe performance”

  1. […] try this out, I applied it to the fractal code I used in an earlier post. In this particular case I can assign an index value to each pixel, instead of a color, and then […]

  2. […] It seems to be much efficient to use haXe than Flash to publish swf, according to Joacim… […]

  3. Pedram says:

    wow, haXe’s performance is awesome!

  4. Optimization says:

    In the AS3 code, move stage.stageWidth and stage.stageHeight to two local variables outside of the loops.

    e.g. for this style of code:

    for(ix=0; ix<stage.stageWidth; ix++) {
    for(iy=0; iy<stage.stageHeight; iy++) {

    …. replace with this style:

    var width:int = stage.stageWidth;
    var height:int = stage.stageHeight;
    for(ix=0; ix<width; ix++) {
    for(iy=0; iy<height; iy++) {