push/pop vs unshift/shift

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Push/Pop
var l = ['a', 'b', 'c', 'd'],
    e;
l.push('e');
e = l.pop();
ready
Unshift/Shift
var l = ['b', 'c', 'd', 'e'],
    a;
l.unshift('a');
a = l.shift();
ready
Push/Access/Pop
var l = ['a', 'b', 'c', 'd'],
    e, v;
l.push('e');
v = l[l.length];
e = l.pop();
ready
Unshift/Access/Shift
var l = ['b', 'c', 'd', 'e'],
    a, v;
l.unshift('a');
v = l[0];
a = l.shift();
ready

Revisions

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