Empty array (v88)

Revision 88 of this benchmark created on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
length
arr.length = 0;
ready
splice
arr.splice(0, arr.length);
ready
pop
while (arr.length > 0) {
  arr.pop();
}
ready
shift
while (arr.length > 0) {
  arr.shift();
}
ready
new array
arr = [];
ready
length 2
arr2.length = 0;
ready
splice 2
arr2.splice(0, arr2.length);
ready
pop 2
while (arr2.length > 0) {
  arr2.pop();
}
ready
shift 2
while (arr2.length > 0) {
  arr2.shift();
}
ready
new array 2
arr2 = []
ready

Revisions

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