Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 YaBrowser/21.6.0.1108 Yowser/2.5 Safari/537.36
Yandex Browser 21
Mac OS X 10.15.7
Desktop
3 years ago
Test name Executions per second
reduce with forEach 7623.7 Ops/sec
flatMap 275.3 Ops/sec
reduce with forEach (directly) 1244.8 Ops/sec
flat 300.6 Ops/sec
reduce with apply 573.4 Ops/sec
for with foreach 641.3 Ops/sec
for with apply 334.4 Ops/sec
nested for 733.0 Ops/sec
reduce with while 11270.6 Ops/sec
while with foreach 1061.3 Ops/sec
while with apply 400.3 Ops/sec
while with for 1353.6 Ops/sec
nested while 1425.8 Ops/sec
nested reduce 7364.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