Clearing Arrays ( without reassigning them )

JavaScript performance comparison

Test case created by Daniel Mendel

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var arr = [], i = 100000, obj = function( seed ){ this['randomizedKey'+(100 / Math.random()*seed)] = Math.PI / Math.random() * seed };
  while( i-- ){
    arr.push( new obj(i) );
  }

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
splice
arr.splice(0,arr.length);
pending…
length = 0
arr.length = 0;
pending…

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

Compare results of other browsers

0 Comments