Array performance

JavaScript performance comparison

Revision 4 of this 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;  }  while (arr.length > 0)    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 arr2 = [];  for (o=0; o<i; o++)    var x = arr2.push(arr[o]);}``
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();  arr.reverse();  arr.reverse();  arr.reverse();  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;  }  while (arr.length > 0)    var x = arr.shift();}``
pending…
create and fill array forwards alternate
``var i,o,arr;for (i=0; i<1024; i++) {  arr = new Array(i);  for (o=0; o<i; o++) {    arr[o]=o;  }}``
pending…
create and fill array forwards alternate 2
``var i,o,arr=[];for (i=0; i<1024; i++) {  var arr2 = new Array(i);  for (o=0; o<i; o++) {    arr[o]=o;  }}``
pending…

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: