object-notation vs constructor (v27)

Revision 27 of this benchmark created by Dmitry Matveev on


Setup

function obj() {
        
      };
    obj.prototype = { 
      a: 1,
      b: 'test',
      c: false
    };
    function emptyobj() {
    };
    function ProtoObj() {}
    ProtoObj.prototype.a = 1;
    ProtoObj.prototype.b = 'test';
    ProtoObj.prototype.a = false;

Test runner

Ready to run.

Testing in
TestOps/sec
object notation
var foo = {
  a: 1,
  b: 'test',
  c: false
};
ready
constructor
var foo = new function() {
    this.a = 1;
    this.b = 'test';
    this.c = false;
  }
ready
prototype
var foo = new obj();
 
ready
empty instance and decorate
var foo = new emptyobj();
foo.a = 1;
foo.b = 'test';
foo.c = false;
ready
empty object and decorate
var foo = {};
foo.a = 1;
foo.b = 'test';
foo.c = false;
ready
prototype (no override)
var foo = new ProtoObj();
ready

Revisions

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