Pop vs Splice (v2)

Revision 2 of this benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
Pop
x.pop();
ready
Splice
x.splice(x.length - 1, 1);
ready
Pop(n)
// Splice generates a result with the removed elements, so, to be fair, so will we
var result = [];

while (x.length > 0) {
  result.push(x.pop());
}
ready
Splice(n)
x.splice(0, x.length);
ready

Revisions

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