On 6/29/17 1:49 AM, T.J. Crowder wrote:
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).

See https://jsperf.com/two-calls-vs-one-no-destructuring/1 which is the same as the above-linked testcase but doesn't do destructuring of an array into an arglist and the collapsing of an arglist into an array for every call. In that one the two-call version is in fact faster.

That is, the cost of allocating and filling the two-element return value array is much smaller than the cost of allocating and filling the 20-element array. Since the two-call testcase in https://jsperf.com/two-calls-vs-one-returning-array does the latter twice, it ends up slower than the version that only does it once.

-Boris
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to