The author here, I ran another test here https://jsben.ch/QCXCY . https://jsbenchmark.com/ seems to have issues with longer running code.
1500 repeats, for me for-of is now on par with classic for. As I said, for-of loops are not optimized as easily and reliably because v8 has to prove certain things to be able to do so. For-of's default is iterator protocol, and its more sensitive to deoptimization.
100% / 92% / ~32% (forget exactly on this one) for for-of, classic, forEach for me, on a Ryzen 5700 AMD desktop. Other things running, not a fantastic test, but I did turn the cooling system up ahead of running. This defied my expectations & I had to try & see!
Side note, I am fantastically glad to see at least some kind of online javascript benchmarking site is alive again. https://jsperf.com was so good to us for so many years. Obviously there's flaws but the way that it not just was a benchmark site but also would record folks results & aggregate them was incredibly incredibly incredibly fantastically sweet.
Got similar results but then tested on an older win10 i5 system (8+ years old?) chrome 145 and get variable results but classic is always about twice foreach or forof and foreach often performs 2x better than forof. I fear this might be more connected to CPUs than anything.
senfiaj|1 month ago
jauntywundrkind|1 month ago
Side note, I am fantastically glad to see at least some kind of online javascript benchmarking site is alive again. https://jsperf.com was so good to us for so many years. Obviously there's flaws but the way that it not just was a benchmark site but also would record folks results & aggregate them was incredibly incredibly incredibly fantastically sweet.
phillipseamore|1 month ago
throw_m239339|1 month ago