loop-testing-kp

JavaScript performance comparison

Revision 4 of this test case created by Karmi Phúc

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var arr = [];
  var i;
  for (i = 0; i < 50000; i++) {
    arr.push('value ' + i);
  }
  var arrLen = arr.length;

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Do while
i = 0;
do {
i++;
}
while (i < arrLen);
pending…
$.each
$.each(arr, function(key, value) {});
pending…
forEach
arr.forEach(function(value) {});
pending…
For loop with arr.Length
for (i = 0; i < arr.length ; i++) {}
pending…
For loop
for (i = 0; i < arrLen ; i++) {}
pending…
For in
for (var key in arr) {}
pending…
While
i = 0;
while (i < arrLen) {
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.

0 Comments