Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0
Firefox 106
Windows
Desktop
2 years ago
Test name Executions per second
Simple for loop 545485.7 Ops/sec
Simple for loop (reverse) 74760.0 Ops/sec
Array.forEach 477154.7 Ops/sec
for loop + Array.entries 40860.5 Ops/sec
while + Array.entries 41548.8 Ops/sec
enumerable for loop (order not important) 10896.6 Ops/sec
enumerable for loop (order is respected) 50410.0 Ops/sec
Array.map 77188.0 Ops/sec
Array.filter 64774.2 Ops/sec
while + Array.entries (condensed) 58083.9 Ops/sec
for loop + Array.entries (condensed) 57742.7 Ops/sec
Simple for loop (condensed) 563489.8 Ops/sec
Instructionless for loop 555848.9 Ops/sec
Script Preparation code:
Tests:
  • Simple for loop

  • Simple for loop (reverse)

  • Array.forEach

  • for loop + Array.entries

  • while + Array.entries

  • enumerable for loop (order not important)

  • enumerable for loop (order is respected)

  • Array.map

  • Array.filter

  • while + Array.entries (condensed)

  • for loop + Array.entries (condensed)

  • Simple for loop (condensed)

  • Instructionless for loop