Array Performance

JavaScript performance comparison

Test case created

Preparation code

<script>

var mSize = 100;

var mArrayNewIndexMiss = new Array();
var mArrayNewIndex = new Array(mSize);
var mArrayNewPush = new Array();

var mArrayIndexMiss = [];
var mArrayPush = [];

var i;

for (i = 0; i < mSize; i++) {
  mArrayNewIndexMiss[i] = {};
  mArrayNewIndex[i] = {};
  mArrayNewPush.push({});
  mArrayIndexMiss[i] = {};
  mArrayPush.push({});
}

</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
New index miss
var tTemp = null;
var tArray = mArrayNewIndexMiss;

for (var i = 0; i < mSize; i++) {
  tTemp = tArray[i];
}
pending…
New index
var tTemp = null;
var tArray = mArrayNewIndex;

for (var i = 0; i < mSize; i++) {
  tTemp = tArray[i];
}
pending…
New push
var tTemp = null;
var tArray = mArrayNewPush;

for (var i = 0; i < mSize; i++) {
  tTemp = tArray[i];
}
pending…
Index miss
var tTemp = null;
var tArray = mArrayIndexMiss;

for (var i = 0; i < mSize; i++) {
  tTemp = tArray[i];
}
pending…
Push
var tTemp = null;
var tArray = mArrayPush;

for (var i = 0; i < mSize; i++) {
  tTemp = tArray[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