Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15
Safari 17
Mac OS X 10.15.7
Desktop
one year ago
Test name Executions per second
Simple for loop 6093.7 Ops/sec
Simple for loop (reverse) 6121.9 Ops/sec
Array.forEach 78662.8 Ops/sec
for loop + Array.entries 9310.9 Ops/sec
while + Array.entries 9225.0 Ops/sec
enumerable for loop (order not important) 4437.5 Ops/sec
enumerable for loop (order is respected) 2444.1 Ops/sec
Array.map 87831.5 Ops/sec
Array.filter 64375.0 Ops/sec
while + Array.entries (condensed) 9497.0 Ops/sec
for loop + Array.entries (condensed) 9200.6 Ops/sec
Simple for loop (condensed) 6299.0 Ops/sec
Instructionless for loop 6325.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


;