pyalot at gmail.com
Thu Jun 29 09:14:04 UTC 2017
A proper test would do this on a few hundred million elements interrupted
every 16.6ms with a RAF so as to give the GC a chance to run and run about
30 seconds so as to trigger at least a couple GC cycles.
On Thu, Jun 29, 2017 at 10:49 AM, T.J. Crowder <
tj.crowder at farsightsoftware.com> wrote:
> On Thu, Jun 29, 2017 at 9:19 AM, Florian Bösch <pyalot at gmail.com> wrote:
> > > Improve performance
> > I doubt that this sequence of calls:
> > min = Math.min(min, value)
> > max = Math.max(max, value)
> > Is slower than this:
> > [min,max] = Math.minmax([min,max,value])
> > Because while the former can get inlined by JIT, the latter can't,
> > and on top, it allocates 2 objects which then have to be GC'ed.
> I was going to make that very point, backed by a jsPerf, but the jsPerf
> doesn't back it up: https://jsperf.com/two-calls-vs-one-returning-array
> It says the minmax is faster on a 10-entry array (it reports the separate
> calls as 46-48% slower on V8 and SpiderMonkey).
> Now, that's comparing making calls to functions defined in userland, not
> ones provided by the engine, so that's an important difference. And there's
> basically no memory pressure, whereas in real life there may be. And it's a
> synthetic benchmark. But there we are.
> -- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss