3 ms·
I tested Firefox, Safari and Brave on macOS. Results are totally different for each. "for loop, positive" seems to be the only safe bet. Safari was very slow on
by fainpul 9mo ago
I tested Firefox, Safari and Brave on macOS. Results are totally different for each. "for loop, positive" seems to be the only safe bet. Safari was very slow on everything, Brave and Firefox were slow on `for … of`.
I'm surprised by the huge variance. Can these results be trusted?
- ygra 9mo agoThe way the array is constructed at least leads to holey arrays in V8. Perhaps similar in other implementations. The performance characteristics between different array types may vary significantly as well. Still, the traditional for loop, counting upwards seems to be fastest for me across Chrome and Firefox on Linux. For-of is slowest by a wide margin.
- nitwit005 9mo agoThere is always going to be a big gap between a browser that had a particular optimization, and one where it is absent. But, browsers are an odd case where optimizations often prove not to be worth it on real world websites. The cost to optimize can easily exceed the savings.