pop vs shift 10 elements on a array (v18)

Revision 18 of this benchmark created on


Description

If you can choose between a .pop() or .shift() 10 elements on a Array, what would be a wise decision?

Test runner

Ready to run.

Testing in
TestOps/sec
.pop()
var array, _i;

array = new Array(2000);

while (array.length > 0) {
  for (_i = 1; _i <= 10; _i++) {
    array.pop();
  }
}
ready
.shift()
var array, _i;

array = new Array(2000);

while (array.length > 0) {
  for (_i = 1; _i <= 10; _i++) {
    array.shift();
  }
}
ready
.splice beginning
var array, i;

array = new Array(2000);

i = array.length;

while (i > 0) {
  array.slice(0, 10);
  i -= 10;
}
ready

Revisions

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