Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Chrome 114
Mac OS X 10.15.7
Desktop
one year ago
Test name Executions per second
reduce with forEach 11399.3 Ops/sec
flatMap 343.6 Ops/sec
reduce with forEach (directly) 991.5 Ops/sec
flat 356.6 Ops/sec
reduce with apply 697.7 Ops/sec
for with foreach 601.2 Ops/sec
for with apply 414.8 Ops/sec
nested for 869.2 Ops/sec
reduce with while 15396.1 Ops/sec
while with foreach 900.8 Ops/sec
while with apply 478.1 Ops/sec
while with for 1581.2 Ops/sec
nested while 1656.4 Ops/sec
nested reduce 11157.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