Empty array (v151)

Revision 151 of this benchmark created by Philippe on


Setup

var sourceArray = [];
    
    for (i=0;i<100000;i++)
       sourceArray.push({a: 1, b: "2"});

Test runner

Ready to run.

Testing in
TestOps/sec
length
var arr = sourceArray.slice();

arr.length = 0;
ready
splice
var arr = sourceArray.slice();

arr.splice(0, arr.length);
ready
pop
var arr = sourceArray.slice();

while (arr.length > 0) {
  arr.pop();
}
ready
shift
var arr = sourceArray.slice();

while (arr.length > 0) {
  arr.shift();
}
ready

Revisions

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