JavaFX script vs ActionScript Performance

how-to
Aug 23, 20082 mins

In a previous post I compared Java performance to that of ActionScript,

Thanks to the efforts of our JavaFX script compiler team (Robert Field, Per Bothner, Brian Goetz) the performance of JavaFX script is now on par with Java in many cases.

Repeating the same Takeuchi benchmark (but with 1000 iterations this time) with JavaFX script vs ActionScript yields the following results:

Here’s the FX script:


function tak(x:Number, y:Number, z:Number): Number {
    if (y >= x) z else tak(tak(x-1, y, z),
                           tak(y-1, z, x),
                           tak(z-1, x, y));
}

for (i in [1..1000]) {
    tak(24, 16, 8);
}

javafxc Tak.fx

With the hotspot server vm:


time javafx -server -cp . Tak

real    0m10.432s
user    0m10.273s
sys     0m0.101s

With the client vm:


time javafx  -cp . Tak

real    0m23.763s
user    0m23.449s
sys     0m0.146s

And here’s the ActionScript (statically typed):

package {
    function tak(x:Number, y:Number , z:Number):Number {
        return y >= x ? z : tak(tak(x-1, y, z),
                                tak(y-1, z, x),
                                tak(z-1, x, y));
    }
    
    var i = 0;
    while (i < 1000) {
        tak(24, 16, 8);
        i++;
    }

}

java -jar asc.jar -import builtin.abc tak.as

tak.abc, 205 bytes written
time ./avmplus tak.abc 

real    2m1.013s
user    1m59.350s
sys     0m0.642s

But, removing the package declaration, yields the following result:

java -jar asc.jar -import builtin.abc tak2.as
tak2.abc, 208 bytes written

time ./avmplus tak2.abc 

real    10m50.701s
user    10m40.793s
sys     0m3.318s

In summary, for this benchmark, with the hotspot server vm, JavaFX script outperforms statically typed ActionScript by a factor of 12, dynamically typed ActionScript by a factor of 65.