keys vs array (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script>
  var o = {};
  for (var i = 0; i < 1000; i++) {
    o[i] = i;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
keys
var data = {};
Object.keys(o).forEach(function(key) {
                                data[key] = o;
                        });
ready
arr
var data = {};
for (var k in o) {
  if (o.hasOwnProperty(k)) data[k] = o;
}
ready
arr without test
var data = {};
for (var k in o) {
 data[k] = o;
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.