large array

JavaScript performance comparison

Test case created by Andrew Silver

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var arr = [], arr2 = [], cnt = 100000;
    for (var i = 0; i < cnt; i++) {
      arr.push(i);
    }
    for (var i = 0; i < cnt; i++) {
      arr2.push(i);
    }
    delete arr2[100];
    delete arr2[2000]
};
</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
one
for (var i = 0; i < cnt; i++) {
  var s = arr[i];
}
pending…
two
for (var i = 0; i < cnt; i++) {
  var s = arr2[i];
}
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