Empty Object Test

JavaScript performance comparison

Test case created by rur

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var obj = {}, 
      obj_sm = {}, 
      i;
  
  for (i = 0; i < 10000; i++) {
    obj["abc_" + i] = null;
  }
  
  for (i = 0; i < 10; i++) {
    obj_sm["abc_" + i] = null;
  }

};
</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
JSON.stringify
JSON.stringify(obj) == '{}'
pending…
JSON.stringify Small
JSON.stringify(obj_sm) == '{}'
pending…
Object.keys
Object.keys(obj).length;
pending…
for var in obj
for(var key in obj) {
  if(obj.hasOwnProperty(key)) break
}
pending…
Object.keys small
Object.keys(obj_sm).length;
pending…
for var in obj small
for(var key in obj_sm) {
  if(obj.hasOwnProperty(key)) break
}
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