Empty array (v87)

Revision 87 of this benchmark created by Jasper on


Preparation HTML

<script>
function clearArray(arr){
   var l = arr.length;
   while( l-- ){
      arr.pop();
   }
   return arr;
}
</script>

Setup

var arr = [];
    var len = (Math.random() * 1000)|0;
    while( len-- ){
    arr.push({ a: Math.random(), b: ""+Math.random() });
    }

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
pop clear (in function)
clearArray( arr );
ready

Revisions

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