JS hash vs object instance

JavaScript performance comparison

Test case created by Xav

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var Obj, hash;
  
  Obj = (function() {
  
    function Obj(x, y, z) {
      this.x = x;
      this.y = y;
      this.z = z;
    }
  
    return Obj;
  
  })();
  
  hash = {};
  

};
</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
Class instance
new Obj(1, 2, 3);
pending…
Hash
hash = {
  x: 1,
  y: 2,
  z: 3
};
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