Run details:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0
Firefox 129
Ubuntu
Desktop
3 months ago
Test name Executions per second
Simple for loop 693028.8 Ops/sec
Simple for loop (reverse) 58682.0 Ops/sec
Array.forEach 130627.0 Ops/sec
for loop + Array.entries 32349.7 Ops/sec
while + Array.entries 29325.7 Ops/sec
enumerable for loop (order not important) 6729.8 Ops/sec
enumerable for loop (order is respected) 36942.6 Ops/sec
Array.map 64313.8 Ops/sec
Array.filter 92147.4 Ops/sec
while + Array.entries (condensed) 44604.2 Ops/sec
for loop + Array.entries (condensed) 39218.0 Ops/sec
Simple for loop (condensed) 616132.2 Ops/sec
Instructionless for loop 679189.6 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