Loops and values access

JavaScript performance comparison

Revision 157 of this test case created by

Preparation code

<script>
  var arr = new Array(100);
</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
while loop that imitates a for loop , caching the length getting value by index access
var i = arr.length;
while (i--) {
  var strigTest = 'one: ' + arr[i] + ' two: ' + arr[i] + ' tree ' + arr[i];
  arr[i];
};
pending…
while loop that imitates a for loop , caching the length getting storing value in var
var i = arr.length;
while (i--) {
  var val = arr[i];
  var strigTest = 'one: ' + val + ' two: ' + val + ' tree ' + val;
  val;
};
pending…
for loop, caching the length getting value by index access
var length = arr.length;
for (var i = 0; i < length; i++) {
  var strigTest = 'one: ' + arr[i] + ' two: ' + arr[i] + ' tree ' + arr[i];
  arr[i];
};
pending…
for loop , caching the length getting storing value in var
var length = arr.length;
for (var i = 0; i < length; i++) {
  var val = arr[i];
  var strigTest = 'one: ' + val + ' two: ' + val + ' tree ' + val;
  val;
};
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