DEV Community

Discussion on: 1 Simple Trick to Boost Performance Using Reduce

Collapse
 
alainvanhout profile image
Alain Van Hout • Edited

Quite interesting! Do note though that these results could also be reduced (thanks, I'll be here all week) to 'one operation takes half as much time as two operations'.

Have you by any chance looked at how a classic for loop does in this test?

Collapse
 
dwilmer profile image
Daan Wilmer • Edited

Good point! I just did that, and this is what I get:

map time (ms): 13755.813225030899
filter time(ms): 3706.2631920576096
reduce time(ms): 3794.9764149188995
for-loop time(ms): 2467.463256955147
Enter fullscreen mode Exit fullscreen mode

Somehow, for me, the map-time takes about four times as long as the other functions (it's weird and I have no clue why), but the for-loop outperforms all others.