Array clear methods (v25)

Revision 25 of this benchmark created by chatcher on


Setup

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

Test runner

Ready to run.

Testing in
TestOps/sec
a.shift();
while(a.length > 0) a.shift();
ready
a.pop();
while(a.length > 0) {
    a.pop();
}
ready
a.splice(0,a.length)
a.splice(0,a.length)
ready
redefine
a = [];
ready
length=0
a.length = 0;
ready

Revisions

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