2109390240913094903904

JavaScript performance comparison

Test case created

Preparation code

<script>
function forwards(a) {
    var sum = 10;
    for( var i = 0, len = a.length; i < len; ++i ) {
        sum += a[i];
    }
    return sum;
}

function backwards(a) {
    var sum = 10;
    var len = a.length;
    while(len--) {
       sum += a[len];
    }
    return sum;
}
var l = 1e5;

var d = [1,2,3,4,5,6,7,8,9,10];
while(l--){
    forwards(d);
    backwards(d);

}

</script>
<script>
Benchmark.prototype.setup = function() {
    var d = [1,2,3,4,5,6,7,8,9,10];
};
</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
forwards
if( forwards(d) !== 65 ) {
die();
}
pending…
backwards
if( backwards(d) !== 65 ) {
die();
}
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment