Array performance

JavaScript performance comparison

Test case created by Christian Sonne

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
create array
var i;
for (i=0; i<1024; i++) {
  var arr = new Array(i);
}
pending…
create and fill array forwards
var i,o;
for (i=0; i<1024; i++) {
  var arr = new Array(i);
  for (o=0; o<i; o++) {
    arr[o]=o;
  }
}
pending…
create and fill array backwards
var i,o;
for (i=0; i<1024; i++) {
  var arr = new Array(i);
  for (o=i-1; o>=0; o--) {
    arr[o]=o;
  }
}
pending…
create, fill and pop
var i,o;
for (i=0; i<1024; i++) {
  var arr = new Array(i);
  for (o=0; o<i; o++) {
    arr[o]=o;
  }
  var x = arr.pop();
}
pending…
create, fill and push
var i,o;
for (i=0; i<1024; i++) {
  var arr = new Array(i);
  for (o=0; o<i; o++) {
    arr[o]=o;
  }
  var x = arr.push("a", 1);
}
pending…
create, fill and reverse
var i,o;
for (i=0; i<1024; i++) {
  var arr = new Array(i);
  for (o=0; o<i; o++) {
    arr[o]=o;
  }
  arr.reverse();
}
pending…
create, fill and shift
var i,o;
for (i=0; i<1024; i++) {
  var arr = new Array(i);
  for (o=0; o<i; o++) {
    arr[o]=o;
  }
  var x = arr.shift();
}
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. Here’s a list of current revisions for this page:

0 comments

Add a comment