Zero filling

JavaScript performance comparison

Test case created by sorensen

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function zeroFill(len) {
      var zero = [];
      while (--len) {
        zero.push(0);
      }
      return zero;
    }
   
    function zeroFill2(len) {
      var zero = new Array(len);
      while (--len) {
        zero[len] = 0;
      }
      return zero;
    }
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
small-1
zeroFill(100);
pending…
small-2
zeroFill2(100);
pending…
large-1
zeroFill(10000);
pending…
large-2
zeroFill2(10000);
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

Add a comment