Script Preparation code:
AخA
 
var arr = [];
var count = 1000;
for(var i = 0; i<count; i++)
{
  arr.push(i);
}
Tests:
  • Cache length

     
    var arrLen = arr.length;
    var sum = 0;
    for (var i = 0; i < arrLen; i++){
      sum += arr[i];
    }
  • Do not cache

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

     
    var sum = 0;
    arr.forEach(item => {
        sum += item
    })
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Cache length
    Do not cache
    forEach

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Cache length 29976.5 Ops/sec
Do not cache 15967.3 Ops/sec
forEach 689370.6 Ops/sec