push allocated vs dynamic

JavaScript performance comparison

Revision 49 of this test case created by Benoit VALLON

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var n=1000000;
  
  

};
</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
push
var myArray = [];
for (var i = 0; i < n; i++) {
  myArray.push(i)
}
pending…
reverse writing
var myArray = [];
var i = n;
while (i--) {
  myArray[i] = i;
}  
pending…
reverse writing, array allocated with Array constructor
var myArray = new Array(n);
var i = n;
while (i--) {
  myArray[i] = i;
}  
pending…
array allocated with Array constructor
var myArray = new Array(n);
var i = 0;
while (i < n) {
  myArray[i] = i;
  i++;
}  
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