Array clear methods (v10)

Revision 10 of this benchmark created on


Setup

var a = [];
  for (var i = 1; i < 100000; i++) {
    a.push(i);
  }

Teardown



            var a = [];
  for (var i = 1; i < 100000; i++) {
    a.push(i);
  }
        
  

Test runner

Ready to run.

Testing in
TestOps/sec
redefine
a = [];
ready
length=0
a.length = 0;
ready
a.splice(0,a.length)
a.splice(0,a.length)
ready
a.pop();
while(a.length) {
    a.pop();
}
ready
while(a.pop()) {}
while(a.pop()) {}
ready
while(a.pop() != undefined) {}
while(a.pop() !== undefined) {}
ready
while--
var len = a.length;
while(len--) a.pop();
ready

Revisions

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