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];
    }
  • for of

     
    var sum = 0;
    for (const ar of arr){
      sum = ar;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Cache length
    Do not cache
    for of

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0
Firefox 94 on Windows
View result in a separate tab
Test name Executions per second
Cache length 577454.2 Ops/sec
Do not cache 519696.2 Ops/sec
for of 92208.0 Ops/sec