Prototype vs Module pattern access performance (v56)

Revision 56 of this benchmark created on


Description

access performance test.

Setup

function TraditionalPrototypeClass() {}
    
    TraditionalPrototypeClass.prototype.foo = function() {};
    
    TraditionalPrototypeClass.prototype.bar = function() {};
    
    function ModulePatternClass() {
      this.foo = function() {};
    
      this.bar = function() {};
    }
    
    var ModuleCachePatternClass = (function() {
      function foo() {}
    
      function bar() {}
    
      return function() {
        this.foo = foo;
        this.bar = bar;
      };
    }());
    
    var standardObject = {
      foo: function() {},
      bar: function() {}
    };
    
    var o1 = new TraditionalPrototypeClass();
    var o2 = new ModulePatternClass();
    var o3 = new ModuleCachePatternClass();
    var o4 = {
      foo: function() {},
      bar: function() {}
    };

Test runner

Ready to run.

Testing in
TestOps/sec
Prototypal
o1.bar;
o1.foo;
ready
Module pattern
o2.bar;
o2.foo;
ready
Module pattern with cached functions
o3.bar;
o3.foo;
ready
Use the right tool for the job
o4.bar;
o4.foo;
ready

Revisions

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