Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
pop() vs shift() vs unshift vs pop
(version: 0)
Comparing performance of:
pop vs shift vs unshift vs push
Created:
4 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var array = []; for(var i = 0; i < 100000; i++){array.push(Math.random());}
Tests:
pop
while (array.length > 0) { array.pop(); }
shift
while (array.length > 0) { array.shift(); }
unshift
let a = []; for(var i = 0; i < 100000; ++i) { a.unshift(i); }
push
let a = []; for(var i = 0; i < 100000; ++i) { a.push(i); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
pop
shift
unshift
push
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:148.0) Gecko/20100101 Firefox/148.0
Browser/OS:
Firefox 148 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
pop
102963016.0 Ops/sec
shift
1583071616.0 Ops/sec
unshift
244.2 Ops/sec
push
1980.8 Ops/sec
Related benchmarks:
Already sorted versus random
Array.Sort vs Math.Min-Max
set.has vs. array.includes vs obj[key] vs map.get 2
Set.has v.s Array.includes
yoooooo
Comments
Confirm delete:
Do you really want to delete benchmark?