noForEach shouldn't be default on #4610
kurtextrem
started this conversation in
General
Replies: 1 comment
-
I think the documentation shouldn't talk about performance for two reasons:
If we removed the "speed" part from the documentation, would you be willing to keep it as recommended? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
noForEach
mentions this:While the latter makes sense, the former doesn't. I've benchmarked forEach vs.
for..of
using mitata in the latest nodejs (v22), as well as in d8 (v8's debug shell) on the latest version (from source) and bench-node to have a third benchmark source.Here's the result in d8:
Latest node:
bench-node:
Source: https://github.com/kurtextrem/foreach-bench
So from the benchmarks (m2 Pro laptop),
forEach
does not seem to be meaningfully slower with large arrays (bench-node result, so guaranteed to be unoptimized), and with mitatas result, forEach even seems slightly faster.Beta Was this translation helpful? Give feedback.
All reactions