Run details:
Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0
Firefox 97
Fedora
Desktop
2 years ago
Test name Executions per second
Simple for loop 918178.3 Ops/sec
Simple for loop (reverse) 13842.8 Ops/sec
Array.forEach 492359.6 Ops/sec
for loop + Array.entries 38729.7 Ops/sec
while + Array.entries 37184.0 Ops/sec
enumerable for loop (order not important) 10629.0 Ops/sec
enumerable for loop (order is respected) 38748.7 Ops/sec
Array.map 95948.5 Ops/sec
Array.filter 77947.7 Ops/sec
while + Array.entries (condensed) 56856.4 Ops/sec
for loop + Array.entries (condensed) 53230.8 Ops/sec
Simple for loop (condensed) 563970.0 Ops/sec
Instructionless for loop 488424.2 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