arraytest

JavaScript performance comparison

Test case created by APXEOLOG

Preparation code

<script>
  Benchmark.prototype.setup = function() {
    var A = [];
    A[0] = { data: 1 };
    A[1] = { data: 1 };
    A[2] = { data: 1 };
    A[3] = { data: 1 };

    var B = [];
    B[0] = { data: 1 };
    B[1] = { data: 1 };
    B[10] = { data: 1 };
    B[100] = { data: 1 };

    var C = {};
    C.index0 = { data: 1 };
    C.index1 = { data: 1 };
    C.index2 = { data: 1 };
    C.index3 = { data: 1 };
  };
</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
Flat array
for (var i = 0; i < 3; i++) A[i].data = i;
pending…
Flat not aligned array
for (var i = 0; i < 3; i++) B[Math.pow(10, i)].data = i;
pending…
Assoc array
for (var i = 0; i < 3; i++) C['index' + i].data = 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. Here’s a list of current revisions for this page:

0 comments

Add a comment