Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Chrome 115
Linux
Desktop
one year ago
Test name Executions per second
Simple for loop 10033.6 Ops/sec
Simple for loop (reverse) 9211.0 Ops/sec
Array.forEach 82159.6 Ops/sec
for loop + Array.entries 15525.3 Ops/sec
while + Array.entries 15796.7 Ops/sec
enumerable for loop (order not important) 7612.6 Ops/sec
enumerable for loop (order is respected) 3243.3 Ops/sec
Array.map 51592.2 Ops/sec
Array.filter 38667.8 Ops/sec
while + Array.entries (condensed) 14989.5 Ops/sec
for loop + Array.entries (condensed) 15241.4 Ops/sec
Simple for loop (condensed) 9538.1 Ops/sec
Instructionless for loop 9538.1 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