Script Preparation code:
x
 
var arr = [];
  for (var i = 0; i < 1000; i++) {
    arr[i] = i;
  }
  function someFn(ix) {
    return ix * 5;
  }
Tests:
  • while

     
    var l = arr.length;
    while(l--) {
      someFn(arr[l]);
    }
  • for

     
    for (var i = 0; i < arr.length; i++) {
      someFn(arr[i]);
    }
  • for 2

     
    var l = arr.length;
    for (var i = 0; i < l; i++) {
      someFn(arr[i]);
    }
  • for 3

     
    var l = arr.length;
    var result=0;
    for (var i = 0; i < l; i++) {
      result += arr[i] * 5;
    }
  • for 4

     
    var result=0;
    for (var i = 0; i < arr.length; i++) {
      result += arr[i] * 5;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    while
    for
    for 2
    for 3
    for 4

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 7 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36
Chrome 58 on Linux
View result in a separate tab
Test name Executions per second
while 7347.5 Ops/sec
for 4936.2 Ops/sec
for 2 7191.0 Ops/sec
for 3 13634.3 Ops/sec
for 4 6854.7 Ops/sec