Array.slice() is up to 40% slower than Array.slice(0)
Reported by
fischer...@gmail.com,
Sep 11
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36
Steps to reproduce the problem:
Just visit jsPerf test
or run this code:
array = [];
for (i = 0; i < 999; i++) array.push(i);
times = [];
time = performance.now();
for (i = 0; i < 9999; i++) array.slice();
times.push(performance.now() - time);
time = performance.now();
for (i = 0; i < 9999; i++) array.slice(0);
times.push(performance.now() - time);
console.log('slice( ): %d\nslice(0): %d', times[0], times[1]);
What is the expected behavior?
The execution time of slice() and slice(0) should be similar
What went wrong?
slice() is around 40% slower than slice(0)
Did this work before? N/A
Chrome version: 69.0.3497.81 Channel: stable
OS Version: OS X 10.13.6
Flash Version:
,
Sep 11
The link for the mentioned jsPerf test: https://jsperf.com/cloning-arrays/3 According to the stats on the jsPerf test page it seems the regression occurred with Chrome version 64 where the performance of slice(0) was improved but slice() not.
,
Sep 11
,
Sep 11
,
Sep 11
Array@slice was optimized in Chrome 70 ( bug v8:7980 ). You can test it in Chrome Canary or beta or dev channel.
,
Sep 13
Thanks woxxom@ for pointing that out. Cc'ing neis@/dhai@ from ( bug v8:7980 ) for inputs.
,
Sep 13
Yes, they are on par now. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 Deleted