shift vs pop

Benchmark created on


Setup

const ITERS = 1_000_000;
let arr = [];
for (let i = 0; i < ITERS; i++) arr.push(i);

Test runner

Ready to run.

Testing in
TestOps/sec
pop 1m
//arr = arr.slice(0, 1_000_000);
while (arr.length) arr.pop();
ready
shift 1m
//arr = arr.slice(0, 1_000_000);
while (arr.length) arr.shift();
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.