Loops

JavaScript performance comparison

Revision 50 of this test case created by Conor Malone

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
    arr = arr.concat(arr, arr, arr, arr, arr, arr, arr, arr, arr);
};
</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
standard for loop
for (var i = 0; i< arr.length; i++) {
  arr[i];
};
pending…
Reverse for loop
var len = arr.length;
for (var i = len; i--;) {
  arr[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