Object.keys vs for

JavaScript performance comparison

Test case created

Preparation code

<script>
  Benchmark.prototype.setup = function() {    
   var results = [];
    for (var i = 100000 - 1; i >= 0; i--) {
        results[i] = i;
    };
  };
</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
Object.keys
Object.keys(results).length;
pending…
For
var value = 0;
for (var vote in results) {
  if (results[vote].votes) {
    value = value + results[vote].votes;
  }
}
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