Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36
Chrome 96
Linux
Desktop
2 years ago
Test name Executions per second
Simple for loop 3288.8 Ops/sec
Simple for loop (reverse) 3166.6 Ops/sec
Array.forEach 30108.5 Ops/sec
for loop + Array.entries 5233.2 Ops/sec
while + Array.entries 5163.1 Ops/sec
enumerable for loop (order not important) 2619.0 Ops/sec
enumerable for loop (order is respected) 1110.2 Ops/sec
Array.map 20779.1 Ops/sec
Array.filter 16640.1 Ops/sec
while + Array.entries (condensed) 5234.0 Ops/sec
for loop + Array.entries (condensed) 5119.0 Ops/sec
Simple for loop (condensed) 3183.3 Ops/sec
Instructionless for loop 3261.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


;