Object keys iteration

JavaScript performance comparison

Revision 7 of this test case created by Jordow

Preparation code

<script>
  var data = {};
  
  for (var i = 0; i < 10000; i++) {
  
   data[i] =  'user ' + i;
  
  }
  data = Object.create(data);
  data.ownField = 'myOwnField';
</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
object-keys 3
var keys = Object.keys(data);
var len = keys.length;
var i;

for (i = 0; i < len; i++) {
  data[keys[i]];
}
pending…
object-keys 2
var keys = Object.keys(data);
var len = keys.length;
var i = 0;

while (i < len) {
   data[keys[i]];
   i++;
}
pending…
for-in
for (var key in data) {
   data[key];
}
pending…
object-keys
Object.keys(data).forEach(function(element, index, array){
  data[element];
});
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