Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
slice VS splice VS shift: who is the fastest to keep constant size (fork no string push)
(version: 0)
100k list splice and shift win, they mutate list slice loose, it creates a copy of list 7.5x slower
Comparing performance of:
slice vs splice vs shift
Created:
3 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var list = []; for (var i = 0; i < 1000 * 1000; i++) { list.push(i); }
Tests:
slice
list = list.slice(1);
splice
list.splice(0, 1);
shift
list.shift();
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
slice
splice
shift
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0
Browser/OS:
Firefox 132 on Ubuntu
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
slice
164.0 Ops/sec
splice
29070012.0 Ops/sec
shift
173746016.0 Ops/sec
Related benchmarks:
slice VS splice: who is the fastest to keep constant size
slice VS splice VS shift: who is the fastest to keep constant size (fork)
slice VS splice VS shift: who is the fastest to keep constant size 100
slice VS splice VS shift: who is the fastest to keep constant size [VARIANT]
Comments
Confirm delete:
Do you really want to delete benchmark?