Run details:
Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36
Chrome 96
Fedora
Desktop
2 years ago
Test name Executions per second
Simple for loop 6544.4 Ops/sec
Simple for loop (reverse) 6187.0 Ops/sec
Array.forEach 72027.0 Ops/sec
for loop + Array.entries 11037.8 Ops/sec
while + Array.entries 11162.7 Ops/sec
enumerable for loop (order not important) 5364.5 Ops/sec
enumerable for loop (order is respected) 2400.8 Ops/sec
Array.map 47079.9 Ops/sec
Array.filter 43020.6 Ops/sec
while + Array.entries (condensed) 12007.7 Ops/sec
for loop + Array.entries (condensed) 11922.6 Ops/sec
Simple for loop (condensed) 6400.6 Ops/sec
Instructionless for loop 6490.3 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