Prototype vs instance functions (v3)

Revision 3 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Instance
var myClass = function(){
    this.method = function(x, y){
        return x + y;
    }
};
var instance = new myClass();
for(var i = 0; i < 1000; i++){
    instance.method(i, 5);
};
ready
Prototype
var myClass = function(){
};

myClass.prototype.method = function(x,y){
    return x + y;
};
var instance = new myClass();
for(var i = 0; i < 1000; i++){
    instance.method(i*2, 32);
};
ready

Revisions

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