Fun with FOR loops and concatenation (v7)

Revision 7 of this benchmark created by afelix on


Description

Comparing minor differences in initiating FOR loops.

Checking difference between caching the array length in a variable before initializing the loop.

Preparation HTML

<script>
  var a = new Array(),
      b = 1000,
      n = '',
      i, j;
  
  for (j = 0; j < b; j = j + 1) {
   a.push(j);
  }
  
  var x = a.length;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Length not cached
for (i; i < a.length; i = i + 1) {
 n = n + i;
}
ready
Length cached
for (i; i < x; i = i + 1) {
 n = n + i;
}
ready

Revisions

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