asm-simple
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
function MyASMNotAnom(stdlib, foreign, heap) {
"use asm";
var sqrt = stdlib.Math.sqrt;
function square(x) {
x = +x;
return +(x * x);
}
function Diag(x, y) {
x = +x; // x has type double
y = +y; // y has type double
return +sqrt(+square(x) + +square(y));
};
return {
Diag: Diag
};
};
var asmMod = MyASMNotAnom({
Math: window.Math
});
var add_asm = (function MyAOTMod(stdlib, foreign, heap) {
"use asm";
var sqrt = stdlib.Math.sqrt;
function square(x) {
x = +x;
return +(x * x);
}
return function(x, y) {
x = +x; // x has type double
y = +y; // y has type double
return +sqrt(+square(x) + +square(y));
};
}(window));
add_asm(12.12, 11.11); //trigger compilation (?)
var add_reg_asmstyle = (function MyAsmLikeRegularMod() {
var sqrt = Math.sqrt;
function square(x) {
x = +x;
return +(x * x);
}
return function(x, y) {
x = +x; // x has type double
y = +y; // y has type double
return +sqrt(+square(x) + +square(y));
};
}());
var add_reg = (function MyStrictProfile() {
"use strict";
var sqrt = Math.sqrt;
function square(x) {
return (x * x)
}
return function(x, y) {
return sqrt(square(x) + square(y));
};
}())
var numbers = [];
for (var i = 0; i < 10000; i += 1) {
numbers.push(Math.random());
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Test | Ops/sec | |
---|---|---|
asm
|
|
pending… |
normal (strict mode)
|
|
pending… |
asm-style (no profile)
|
|
pending… |
asm-no-anon-func
|
|
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.
- Revision 1: published
- Revision 2: published
- Revision 6: published
- Revision 7: published
- Revision 10: published and last updated
- Revision 12: published
- Revision 15: published
- Revision 16: published
- Revision 17: published
- Revision 18: published
- Revision 21: published 0xAnim
- Revision 23: published
- Revision 24: published Jason
0 Comments