asm mark 2

JavaScript performance comparison

Test case created by Calvin Metcalf

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 };
}
function DiagModule2(stdlib) {
 

    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 asm = DiagModule(window);
var noasm = DiagModule2(window);
var as = [2,4,7,4,5];
var bs = [4,6,8,4,5];
var len = 5;
</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
asm
var i = 0;
while(i<len){
asm.diag(as[i],bs[i]);
i++;
}
pending…
no asm
var i = 0;
while(i<len){
noasm.diag(as[i],bs[i]);
i++;
}
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