Run details:
Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0
Firefox 101
Linux
Desktop
2 years ago
Test name Executions per second
Simple for loop 1064982.4 Ops/sec
Simple for loop (reverse) 107832.2 Ops/sec
Array.forEach 817335.4 Ops/sec
for loop + Array.entries 52488.2 Ops/sec
while + Array.entries 53178.7 Ops/sec
enumerable for loop (order not important) 13094.6 Ops/sec
enumerable for loop (order is respected) 30175.3 Ops/sec
Array.map 82334.5 Ops/sec
Array.filter 73646.1 Ops/sec
while + Array.entries (condensed) 84498.7 Ops/sec
for loop + Array.entries (condensed) 85731.2 Ops/sec
Simple for loop (condensed) 823246.2 Ops/sec
Instructionless for loop 794056.7 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