asmjs
JavaScript performance comparison
Preparation code
<script>
function DiagModule(stdlib) {
"use asm";
var sqrt = stdlib.Math.sqrt;
function square(x) {
x = +x;
return +(x*x);
}
function diag(x, y) {
x = +x;
y = +y;
return +sqrt(+square(x) + +square(y));
}
return { diag: diag };
}
var fast = DiagModule(window);
function DiagModule2(stdlib) {
"use asm";
var sqrt = stdlib.Math.sqrt;
function square(x) {
x = +x;
return +(x*x);
}
function diag(x, y) {
x = +x;
y = +y;
return +sqrt(+square(x) + +square(y));
}
return { diag: diag };
}
var bogusGlobal = {
Math: {
sqrt: function(x) { return x * 2; }
}
};
var slow = DiagModule2(bogusGlobal); // produces purelyinterpreted version
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test  Ops/sec  

fast 

pending… 
slow 

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:
 Revision 1: published and last updated
 Revision 2: published
 Revision 3: published
 Revision 4: published
 Revision 5: published
 Revision 6: published
 Revision 7: published
 Revision 8: published
 Revision 9: published
 Revision 12: published
0 comments