Pop vs Splice vs Length (v5)

Revision 5 of this benchmark created on


Setup

x = window.x = [];
    for (var i = 0; i < 10000; ++i) {
      x.push(i);
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Pop
var n = 10;
var x = window.x;
for (;n-->0;) {
  x[x.indexOf(n*200)] = x[x.length-1];
  x.pop();
}
ready
Splice
var n = 10;
var x = window.x;
for (;n-->0;) {
  x.splice(x.indexOf(n*200), 1);
}
ready
Length
var n = 10;
var x = window.x;
var len = x.length-1;
for (;n-->0;) {
  x[x.indexOf(n*200)] = x[len--];
  if (len >= 0) x.length = len;
}
ready

Revisions

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