Closed Bug 1408039 Opened 7 years ago Closed 6 years ago

Spread ...args are 99% slower than arguments

Categories

(Core :: JavaScript Engine, defect, P2)

defect

Tracking

()

RESOLVED WORKSFORME
Performance Impact low
Tracking Status
firefox58 --- affected

People

(Reporter: glex.spb, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: perf, Whiteboard: [js:perf])

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 Steps to reproduce: Benchmarked these three functions: function sumArguments(a, b) { if (arguments.length !== 2) return -100; return a + b; } function sumSpreadDestructure(...args) { if (args.length !== 2) return -100; let [a, b] = args; return a + b; } function sumSpreadIndex(...args) { if (args.length !== 2) return -100; let a = args[0], b = args[1]; return a + b; } https://jsperf.com/arity-checking-spread-vs-arguments Actual results: The ...args versions are 99% slower than the arguments version in both Firefox and Nightly (Windows 10). Expected results: All three functions perform roughly the same (+- 30%). E.g. in Chrome all 3 are fast, and the ...args versions are ~15% faster than the arguments one.
Blocks: es6perf
Keywords: perf
Priority: -- → P2
Whiteboard: [js:perf][qf:p3]

Tried running the benchmark and the performance is all similar now. (Values are 1,814,783,470 / 1,802,237,367 / 1,759,341,094 respectively.)

I tried as well and got similar result.
This issue seems to be fixed now.

Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
Performance Impact: --- → P3
Whiteboard: [js:perf][qf:p3] → [js:perf]
You need to log in before you can comment on or make changes to this bug.