Tests:
  • foreach

    x
     
    const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
    let index = 0;
    items.forEach(i => index++);
  • for-in

     
    const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
    let index = 0;
    for (let i in items) {
        index++;
    }
  • for-of

     
    const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
    let index = 0;
    for (let i of items) {
        index++;
    }
  • for

     
    const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
    let index = 0;
    for(let i = 0; i < items.length; ++i) {
      index++;
    }
  • optimized-for

     
    const items = Array.from({length: 1000}, () => Math.floor(Math.random() * 40));
    let index = 0;
    for(let i = items.length; i > 0; --i) {
      index++;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    foreach
    for-in
    for-of
    for
    optimized-for

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 6 hours ago)
Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/135.0.7049.83 Mobile/15E148 Safari/604.1
Chrome Mobile iOS 135 on iOS 18.3.2
View result in a separate tab
Test name Executions per second
foreach 235276.0 Ops/sec
for-in 26673.7 Ops/sec
for-of 205696.7 Ops/sec
for 252250.8 Ops/sec
optimized-for 231390.8 Ops/sec