Emptying an array - Trying to force GC

JavaScript performance comparison

Revision 28 of this test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var arr = [];
  for(var i = 0, len = 25 * 1024 * 1024; i < len; i++) // runs 25 to 100 times = some mb
  {
      arr.push('a');
  }

};
</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
Creating a new empty array
arr = [];

setTimeout(function(){}, 1); // give the GC some time to kick in
pending…
Pop
    while (arr.length) {
        arr.pop();
    }

setTimeout(function(){}, 1); // give the GC some time to kick in
pending…
Setting .length to 0

arr.length = 0;

setTimeout(function(){}, 1); // give the GC some time to kick in
pending…

Compare results of other browsers

Revisions

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

0 Comments