Looping testing

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var l = 1e3, values = [];
    while (l--) {
      values.push(Math.random() * 1e4);
    }
   
    function process (i) {
      i*=2;
    }
};
</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
//for loop
var length = values.length;

for (var i=length; i--;){
    process(values[i]);
}
 
pending…
//do-while loop
var length = values.length;

var j=length;
do {
    process(values[--j]);
} while (j);

 
pending…
//while loop
var length = values.length;

var k=length;
while (k--){
    process(values[k]);
}
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