Status: Untriaged
Owner: ----
New issue 4129 by [email protected]: array.length = 0 slower than splice
https://code.google.com/p/v8/issues/detail?id=4129
According to https://jsperf.com/array-destroy/40, comparing these two ways
to clear an array:
1) arr.length = 0;
2) arr.splice(0, arr.length);
Apparently splice() is faster. Some results comparing Chrome and Firefox:
Chrome 45.0.2405.0 canary (64-bit) / Windows
length = 0: 5,463,503 ops/sec
splice: 9,088,803 ops/sec
Firefox Nightly 41.0a1 / Windows
length = 0: 34,535,478 ops/sec
splice: 7,801,437 ops/sec
splice() is faster in Chrome, but length = 0 is faster in Firefox. It would
be nice if arr.length = 0 could be as fast as splicing it to empty... and
even better if it can be as fast as Firefox!
Note: I haven't checked it's a fair test, maybe it's optimising things
away, which I think some of the other tests are doing because they get
crazy high scores.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.