Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15
Safari 14
Mac OS X 10.15.7
Desktop
2 years ago
Test name Executions per second
reduce with forEach 3556.3 Ops/sec
flatMap 6194.9 Ops/sec
reduce with forEach (directly) 3946.8 Ops/sec
flat 3164.8 Ops/sec
reduce with apply 533.8 Ops/sec
for with foreach 590.8 Ops/sec
for with apply 292.5 Ops/sec
nested for 667.0 Ops/sec
reduce with while 9439.8 Ops/sec
while with foreach 1029.0 Ops/sec
while with apply 372.3 Ops/sec
while with for 524.4 Ops/sec
nested while 883.2 Ops/sec
nested reduce 2536.2 Ops/sec
reduce with while plus 16084.6 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

  • reduce with while plus