Prototype vs Module pattern performance (v96)

Revision 96 of this benchmark created on


Setup

function Klass () {
    }
    Klass.prototype.foo = function() {
        alert('foo');
    }
    Klass.prototype.bar = function() {
        alert('bar');
    }
    Klass.prototype.foo1 = function() {
        alert('foo');
    }
    Klass.prototype.bar1 = function() {
        alert('bar');
    }
    
    Klass.prototype.foo2 = function() {
        alert('foo');
    }
    Klass.prototype.bar2 = function() {
        alert('bar');
    }
    
    Klass.prototype.foo3 = function() {
        alert('foo');
    }
    Klass.prototype.bar3 = function() {
        alert('bar');
    }
    Klass.prototype.foo4 = function() {
        alert('foo');
    }
    Klass.prototype.bar4 = function() {
        alert('bar');
    }
    
    function foo() {
    }
    
    function bar() {
    }
    
    function bar1() {
    }
    
    function foo1() {
    }
    
    function foo2() {
    }
    
    function bar2() {
    }
    
    function foo3() {
    }
    
    function bar3() {
    }
    
    function foo4() {
    }
    
    function bar4() {
    }
    
    
    function Klass2 () {
        return {
    foo: foo,
    bar: bar,
    foo1: foo1,
    bar1: bar1,
    foo2: foo2,
    bar2: bar2,
    foo3: foo3,
    bar3: bar3,
    foo4: foo4,
    bar4: bar4
    };
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Prototypal
new Klass();
ready
Module pattern
new Klass2();
ready

Revisions

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