Prototype vs Module pattern performance (v75)

Revision 75 of this benchmark created on


Setup

function context() {
       var ins = {};
       ins.prop1 = 'asdasd';
       ins.prop2 = 'asdsad';
       ins.prop3 = 'asdasd';
       ins.prop4 = 'asdasd';
       ins.prop5 = 'sdasd';
       ins.testMethod = function() {
          return ins.prop1;
       }
       return ins;
    }
    
    function Context() {
       var ins = this;
       ins.prop1 = 'asdasd';
       ins.prop2 = 'asdsad';
       ins.prop3 = 'asdasd';
       ins.prop4 = 'asdasd';
       ins.prop5 = 'sdasd';
       ins.testMethod = function() {
          return ins.prop1;
       }
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Prototypal
var a = context();
a.testMethod();
ready
Module pattern
var b = new Context();
b.testMethod();
ready
asdsadasd
var c = context2();
c.testMethod();
ready

Revisions

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