Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
pop() vs shift() vs unshift vs pop vs index
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:95.0) Gecko/20100101 Firefox/95.0
Browser:
Firefox 95
Operating system:
Fedora
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
pop
78021936.0 Ops/sec
shift
382079296.0 Ops/sec
unshift
46.2 Ops/sec
push
373.4 Ops/sec
index
387.2 Ops/sec
Script Preparation code:
var array = new Array(100000); for(let i = 0; i < 100000; ++i) { array[i] = i; }
Tests:
pop
while (array.length > 0) { array.pop(); }
shift
while (array.length > 0) { array.shift(); }
unshift
let a = []; for(let i = 0; i < 100000; ++i) { a.unshift(i); }
push
let a = []; for(let i = 0; i < 100000; ++i) { a.push(i); }
index
let a = new Array(100000); for(let i = 0; i < 100000; ++i) { a[i] = i; }