Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Shift/Pop
(version: 2)
Comparing performance of:
shift vs pop vs splice(shift) vs splice(pop)
Created:
6 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
window.n = 100000;
Tests:
shift
arr = Array.from(new Array(n)).map((_,i)=>i) for(let i = 0; i < n; i++){ arr.shift() }
pop
arr = Array.from(new Array(n)).map((_,i)=>i) for(let i = 0; i < n; i++){ arr.pop() }
splice(shift)
arr = Array.from(new Array(n)).map((_,i)=>i) for(let i = 0; i < n; i++){ arr.splice(0, 1) }
splice(pop)
arr = Array.from(new Array(n)).map((_,i)=>i) for(let i = 0; i < n; i++){ arr.splice(n-i-1, 1) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
shift
pop
splice(shift)
splice(pop)
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser/OS:
Chrome 130 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
shift
2.1 Ops/sec
pop
40.4 Ops/sec
splice(shift)
1.9 Ops/sec
splice(pop)
25.3 Ops/sec
Related benchmarks:
Setting Canvas Pixel
Setting Canvas Pixel
Setting Canvas Pixel
Setting multiple canvas pixels
Setting multiple canvas pixels
Comments
Confirm delete:
Do you really want to delete benchmark?