13 ms·
When I wrote it I ran that JS code through several rounds of benchmarking to try and eke out some more performance. One of the tweaks I tried was collapsing all
by josephg 10y ago
When I wrote it I ran that JS code through several rounds of benchmarking to try and eke out some more performance. One of the tweaks I tried was collapsing all the calculations together to use fewer variables to see if that would make it faster.
Performance was totally unchanged either way. Looks like V8's optimizer eats those vars for breakfast.
- jcranmer 10y agoIn general, at the optimization IR level of any decent compiler or JIT, most straight-line code gets reduced into some form of expression DAG for common subexpression elimination and other similar optimizations, meaning that var x = a + b; call(x + c); and call(a + b + c); would be literally indistinguishable.