Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Safari/605.1.15
Safari 13
Mac OS X 10.15.7
Desktop
3 years ago
Test name Executions per second
reduce with forEach 3333.1 Ops/sec
flatMap 6368.3 Ops/sec
reduce with forEach (directly) 4239.0 Ops/sec
flat 3368.6 Ops/sec
reduce with apply 531.1 Ops/sec
for with foreach 619.8 Ops/sec
for with apply 310.4 Ops/sec
nested for 700.7 Ops/sec
reduce with while 10189.8 Ops/sec
while with foreach 1089.5 Ops/sec
while with apply 388.8 Ops/sec
while with for 1338.8 Ops/sec
nested while 1398.1 Ops/sec
nested reduce 2867.5 Ops/sec
Script Preparation code:
Tests:
  • reduce with forEach

  • flatMap

  • reduce with forEach (directly)

  • flat

  • reduce with apply

  • for with foreach

  • for with apply

  • nested for

  • reduce with while

  • while with foreach

  • while with apply

  • while with for

  • nested while

  • nested reduce