Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0
Firefox 102
Windows
Desktop
2 years ago
Test name Executions per second
Simple for loop 905570.3 Ops/sec
Simple for loop (reverse) 73461.9 Ops/sec
Array.forEach 483139.5 Ops/sec
for loop + Array.entries 33659.1 Ops/sec
while + Array.entries 38878.5 Ops/sec
enumerable for loop (order not important) 11192.7 Ops/sec
enumerable for loop (order is respected) 32441.1 Ops/sec
Array.map 75255.5 Ops/sec
Array.filter 61484.6 Ops/sec
while + Array.entries (condensed) 62203.4 Ops/sec
for loop + Array.entries (condensed) 58520.0 Ops/sec
Simple for loop (condensed) 555664.8 Ops/sec
Instructionless for loop 479127.5 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