Re:Math.min(Math.max(num, min), max)
by saagarjha on Thursday August 20, 2020 @03:52PM
(#24227979)
I was curious how slow this would be, and here is what JavaScriptCore made of this code:
However, I was pretty disappointed when it seemed to be calling sort each time :( Perhaps I profiled it incorrectly? jsc's profiling data shows that it never hit FTL and nothing ever got inlined. The bytecode for DFG and Baseline is identical:
[ Parent
| on HN ]
Dude, you are generating random numbers inside the loop. That is going to dominate runtime.