FIFO unshift/pop vs push/shift

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var src = ['a'], dest = null;
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
unshift/pop
dest = null;
src = ['a'];
src.unshift('b');
src.unshift('c');
src.unshift('d');
dest = src.pop();
dest = src.pop();
dest = src.pop();
pending…
push/shift
dest = null;
src = ['a'];
src.push('b');
src.push('c');
src.push('d');
dest = src.shift();
dest = src.shift();
dest = src.shift();
pending…
length/shift
dest = null;
src = ['a'];
src[src.length] = 'b';
src[src.length] = 'c';
src[src.length] = 'd';
dest = src.shift();
dest = src.shift();
dest = src.shift();
 
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment