Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.135 YaBrowser/21.6.2.867 Yowser/2.5 Safari/537.36
Yandex Browser 21
Mac OS X 10.15.6
Desktop
3 years ago
Test name Executions per second
reduce with forEach 7783.9 Ops/sec
flatMap 300.0 Ops/sec
reduce with forEach (directly) 1278.2 Ops/sec
flat 297.6 Ops/sec
reduce with apply 590.2 Ops/sec
for with foreach 649.5 Ops/sec
for with apply 339.6 Ops/sec
nested for 752.1 Ops/sec
reduce with while 11774.5 Ops/sec
while with foreach 1066.4 Ops/sec
while with apply 441.7 Ops/sec
while with for 1409.6 Ops/sec
nested while 1504.4 Ops/sec
nested reduce 7844.0 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