Prototype vs Module pattern performance (v103)

Revision 103 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Prototypal
Klass = function() {}
Klass.prototype.foo = function() {
  alert('foo');
}
Klass.prototype.bar = function() {
  alert('bar');
}

var i = 1000,
    objs = [];
while (i--) {
  objs.push(new Klass());
}
ready
Module pattern
Klass = {
  var foo = function {
      alert('foo';
      };
      var bar = function {
          alert('bar';
          };
          return {
            foo: foo,
            bar: bar
          }
          }
          
          
          
      var i = 1000,
          objs = [];
      while (i--) {
        objs.push(new Klass());
      }
ready

Revisions

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