pop vs shift (v2)

Revision 2 of this benchmark created by Igor Minar on


Setup

var a, i;
  
  Benchmark.prototype.setup = function() {
   a = [];
   i = 1000;
   while (i--) {
    a.push('x');
   }
  }

Test runner

Ready to run.

Testing in
TestOps/sec
unshift+pop
a.unshift('x');
a.pop();
ready
push+shift
a.push('x');
a.shift();
ready
push+pop
a.push('x');
a.pop();
ready

Revisions

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

  • Revision 1: published by Igor Minar on
  • Revision 2: published by Igor Minar on
  • Revision 3: published by Igor Minar on