I'd also be cautious about what kind of testing you do because (1) microbenchmarks are not realistic, (2) perf measurements themselves skew measurements when you're measuring something with extremely low overhead like a simple loop.
if measurements for both versions are equally skewed, doesn't it cancel it out? I'm measuring the comparisons of 2 functions, not the 1 function itself.
microbenchmarks are not realistic
with this, I can't argue since every situation is different and you can't really measure anything like that reliably.
1
u/andrei9669 Dec 05 '21
pretty much. and I did some testing today. and I came to the conclusion, that forEach is almost the same as regular for loop.