Spread operator up to 3.5 times slower than apply()

UNCONFIRMED
Unassigned

Status

()

Core
JavaScript Engine
P3
normal
UNCONFIRMED
11 months ago
2 months ago

People

(Reporter: CoolCmd, Unassigned)

Tracking

(Blocks: 1 bug)

56 Branch
x86_64
Unspecified
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

11 months ago
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
Build ID: 20170719030206

Steps to reproduce:

see testcase: https://jsfiddle.net/CoolCmd/3b11kyda/
click the "run tests" button at the bottom right corner



Actual results:

apply x 55,472 ops/sec
spread x 16,328 ops/sec

this code
    String.fromCodePoint(...a)
is 3.5x slower than
    String.fromCodePoint.apply(this, a)


Expected results:

Chrome 58:
apply x 45,313 ops/sec
spread x 45,326 ops/sec

Edge 15:
apply x 58,834 ops/sec
spread x 31,114 ops/sec
(Reporter)

Updated

11 months ago
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Hardware: Unspecified → x86_64

Updated

11 months ago
Blocks: 1307395

Comment 1

11 months ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:54.0) Gecko/20100101 Firefox/54.0
Build ID: 20170628075643

I have also noticed significantly worse performance of the Spread Operator.

I was looking for the least intensive method of concatenating arrays and found the answer in the first reference link. However, in testing with the Javascript performance test site in the second reference link, the Spread Operator performed noticeably worse than apply and concat. When I passed along the same test to a PC Chrome user, they reported the Spread Operator being the least intensive variant.

Running the test on Mobile versions of both browsers had identical results: Firefox's implementation is always slower. As per this report and its parent report, fixes are required for reliability and efficiency.

References:
- https://stackoverflow.com/a/5081471/5857393
- http://jsben.ch/rVji3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.