Object Iteration Comparison

JavaScript performance comparison

Test case created by

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var dataAttribs = {
    "p1": "value1",
    "p2": "value2",
    "p3": "value3",
    "p4": "value4",
    "p5": "value5",
    "p6": "value6",
    "p7": "value7",
    "p8": "value8",
    "p9": "value9",
    "p10": "value10",
    "p11": "value11",
    "p12": "value12",
    "p13": "value13",
    "p14": "value14",
    "p15": "value15",
    "p16": "value16",
    "p17": "value17",
    "p18": "value18",
  };
  var data = {
    "exist1": "value1",
    "exist2": "value2",
    "exist3": "value3",
  };

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
For-In Loop
for (var key in dataAttribs) {
  data[key] = dataAttribs[key];
}
pending…
For Loop
for (var i = 0; i < dataAttribs.length; i++) {
  data[dataAttribs[i].name] = dataAttribs[i].value;
};
pending…
Object Keys
var keys = Object.keys(dataAttribs),
  len = keys.length,
  i = 0,
  key;

while (i < len) {
  key = keys[i];
  data[key] = dataAttribs[key];
  i += 1;
}
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.

0 Comments