Typing arrays for objects

JavaScript performance comparison

Test case created by Joshua

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var testObject = {
      firstname: 'john',
      lastname: 'doe',
      age: 30,
      height: 5.5,
      cool: true
    };
    var array1 = [];
    var array2 = []
    array2[0] = {};
    var array3 = new Array(1000);
    var array4 = new Array(1000);
    array4[0] = {};
};
</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
Non-typed array
for (var i = 0; i < 1000; i++) {
  array1.push(testObject);
}
pending…
Typed array
for (var i = 0; i < 1000; i++) {
  array2.push(testObject);
}
pending…
Non-typed sized array
for (var i = 0; i < 1000; i++) {
  array3.push(testObject);
}
pending…
Typed sized array
for (var i = 0; i < 1000; i++) {
  array4.push(testObject);
}
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