Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
slice VS splice VS shift: who is the fastest to keep constant size (fork no string push)
(version: 0)
Benchmark.js
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:
4 years ago
by:
Registered User
Go 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
shift
173.7M/s
splice
29.1M/s
slice
164/s
View exact numbers
Test name
Executions per second
✓
shift
173,746,016 Ops/sec
splice
29,070,012 Ops/sec
slice
164 Ops/sec
Related benchmarks
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?