If you're using Math.hypot in hot code paths, do you know how slow it is? I'm profiling some JS in @ChromeDevTools and Math.hypot(x, y) is eating a huge chunk of time. Math.sqrt(x*x + y*y) is over 50x faster (!!) with a million iterations. (x*x + y*y) ** 0.5 is a bit faster still
-
-
Thanks to both of you! (And anyone else who helped.) The speed at which
@bmeurer put this fix together is very impressive, and the perf gains look great. Excited Math.hypot is back on the table!
-
I also learned a few tricks on how to write a better micro-benchmark for JS engines after reading the one
@bmeurer wrote here. For one thing, polluting early call feedback is smart! https://github.com/bmeurer/js-micro-benchmarks/blob/60a34c0dd29b77e6950555c2dd9687b1a0a7671e/bench-math-hypot.js … - 1 more reply
New conversation -
-
-
Just curiosity, why did the `DCHECK_GT(max, 0);` change to `DCHECK(!(max <= 0));` in http://builtins-math.cc ?
-
NaN propagation
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.