asmjs

JavaScript performance comparison

Revision 2 of this test case created by Calvin Metcalf and last updated

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
   
    var asm = new Function("stdlib", " \"use asm\";\n var pow = stdlib.Math.pow;\n\n function mandlebrot(cx, cy, maxIter) {\n    cx = +cx;\n     cy = +cy;\n     maxIter = maxIter|0;\n     var iter=0;\n     var xn= 0.0;\n     var x = 0.0;\n     var y = 0.0;\n     while ( ((pow(x,2.0) + pow(y,2.0)) < 4.0)&((iter|0) < (maxIter|0))) {\n         xn = +( pow(x,2.0) - pow(y,2.0) + cx);\n         y = +((x*y)*2.0 + cy);\n         x = +xn;\n         iter=(iter+1)|0;\n     }\n     \n     return iter|0;\n }\n return {\n mandlebrot: mandlebrot\n};");
   
    var noasm =new Function("stdlib", " var pow = stdlib.Math.pow;\n\n function mandlebrot(cx, cy, maxIter) {\n    cx = +cx;\n     cy = +cy;\n     maxIter = maxIter|0;\n     var iter=0;\n     var xn= 0.0;\n     var x = 0.0;\n     var y = 0.0;\n     while ( ((pow(x,2.0) + pow(y,2.0)) < 4.0)&((iter|0) < (maxIter|0))) {\n         xn = +( pow(x,2.0) - pow(y,2.0) + cx);\n         y = +((x*y)*2.0 + cy);\n         x = +xn;\n         iter=(iter+1)|0;\n     }\n     \n     return iter|0;\n }\n return {\n mandlebrot: mandlebrot\n};");
    var withasm=asm(window);
    var withoutasm=noasm(window);
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Regular
withoutasm.mandlebrot(0,0,500)
pending…
asm
withasm.mandlebrot(0,0,500)
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment