Script Preparation code:
AخA
 
var set = new Set(Array.from(Array(1000).keys())
.map((x) => `item--${x}`))
Tests:
  • Foor loop

     
    for (var val of set) {
      console.log(val);
    }
  • for loop with const length

     
    const arr = [...set]
    let length = arr.length
    for (let i = 0; i < length; i++) {
        console.log(arr[i])
    }
  • for loop

     
    const arr = [...set]
    for (let i = 0; i < arr.length; i++) {
        console.log(arr[i])
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Foor loop
    for loop with const length
    for loop

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Chrome 119 on Windows
View result in a separate tab
Test name Executions per second
Foor loop 268.2 Ops/sec
for loop with const length 286.9 Ops/sec
for loop 294.2 Ops/sec