myclassperf

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
new
function extend() {
    var len = arguments.length;
    var body = arguments[len - 1];
    var parent = (len > 1) ? arguments[0] : Function.constructor;
    body.prototype = new parent;
    //console.log(parent.prototype)

    var constructor = new body;
    constructor._super = parent.prototype;
    if (!constructor.hasOwnProperty("init")) return body;
    constructor.init.prototype = constructor;
    return constructor.init;
}

function A1() {this.a1=12324233243;}
A1.prototype.a2=222222;

var A = extend(A1, function () {
console.log(1)
    this.pro1 = 'pro1 ';
    this.method1 = function() {
        return this.pro1;
    }
    this.init = function(a) {
       // console.log("init1", a)
        //this._super.init("caca")
    }
});
var B = extend(A, function() {
console.log(2)
    this.pro2 = 'pro2 ';
    this.init = function(a) {
        //console.log("init2", a)
        //this._super.init("caca")
    };
    this.method2 = function() {
        return this.pro1 + this.pro2;
    };
});
/*var C = extend(B, function() {
    this.pro3 = 'pro3 ';
    this.method3 = function() {
        return this;
    };
    this.init = function(a) {
        console.log("init3", a)
        this._super.init("caca")
    }
});*/
//c = new C("parameter of the constructor")
ins=new B("parameter")
console.log(ins instanceof B, ins)
ready
copying prototype
function extend() {
    var len = arguments.length;
    var body = arguments[len - 1];
    var parent = (len > 1) ? arguments[0] : Function.constructor;
    body.prototype = parent.prototype;
    //console.log(parent.prototype)

    var constructor = new body;
    constructor._super = parent.prototype;
    if (!constructor.hasOwnProperty("init")) return body;
    constructor.init.prototype = constructor;
    return constructor.init;
}

function A1() {this.a1=12324233243;}
A1.prototype.a2=222222;

var A = extend(A1, function () {
console.log(1)
    this.pro1 = 'pro1 ';
    this.method1 = function() {
        return this.pro1;
    }
    this.init = function(a) {
       // console.log("init1", a)
        //this._super.init("caca")
    }
});
var B = extend(A, function() {
console.log(2)
    this.pro2 = 'pro2 ';
    this.init = function(a) {
        //console.log("init2", a)
        //this._super.init("caca")
    };
    this.method2 = function() {
        return this.pro1 + this.pro2;
    };
});
/*var C = extend(B, function() {
    this.pro3 = 'pro3 ';
    this.method3 = function() {
        return this;
    };
    this.init = function(a) {
        console.log("init3", a)
        this._super.init("caca")
    }
});*/
//c = new C("parameter of the constructor")
ins=new B("parameter")
console.log(ins instanceof B, ins)
ready
othr
function extend() {
    var len = arguments.length;
    var body = arguments[len - 1];
    var parent = (len > 1) ? arguments[0] : Function.constructor;
    body.prototype = parent.prototype;
    //console.log(parent.prototype)

    var constructor = new body;
    if (!constructor.hasOwnProperty("init")) return body;
    constructor._super = parent.prototype;
    constructor.init.prototype = constructor;
    return constructor.init;
}

function A1() {this.a1=12324233243;}
A1.prototype.a2=222222;

var A = extend(A1, function () {
console.log(1)
    this.pro1 = 'pro1 ';
    this.method1 = function() {
        return this.pro1;
    }
    this.init = function(a) {
       // console.log("init1", a)
        //this._super.init("caca")
    }
});
var B = extend(A, function() {
console.log(2)
    this.pro2 = 'pro2 ';
    this.init = function(a) {
        //console.log("init2", a)
        //this._super.init("caca")
    };
    this.method2 = function() {
        return this.pro1 + this.pro2;
    };
});
/*var C = extend(B, function() {
    this.pro3 = 'pro3 ';
    this.method3 = function() {
        return this;
    };
    this.init = function(a) {
        console.log("init3", a)
        this._super.init("caca")
    }
});*/
//c = new C("parameter of the constructor")
ins=new B("parameter")
console.log(ins instanceof B, ins)
ready
asa
function extend() {
    var len = arguments.length;
    var body = arguments[len - 1];
    var parent = (len > 1) ? arguments[0] : Function.constructor;
    body.prototype = parent.prototype;
    //console.log(parent.prototype)

    var constructor = new body;
    if (!constructor.hasOwnProperty("init")) return body;
    constructor._super = parent.prototype.init;
    constructor.init.prototype = constructor;
    return constructor.init;
}

function A1() {this.a1=12324233243;}
A1.prototype.a2=222222;

var A = extend(A1, function () {
console.log(1)
    this.pro1 = 'pro1 ';
    this.method1 = function() {
        return this.pro1;
    }
    this.init = function(a) {
       // console.log("init1", a)
        //this._super.init("caca")
    }
});
var B = extend(A, function() {
console.log(2)
    this.pro2 = 'pro2 ';
    this.init = function(a) {
        //console.log("init2", a)
        //this._super.init("caca")
    };
    this.method2 = function() {
        return this.pro1 + this.pro2;
    };
});
/*var C = extend(B, function() {
    this.pro3 = 'pro3 ';
    this.method3 = function() {
        return this;
    };
    this.init = function(a) {
        console.log("init3", a)
        this._super.init("caca")
    }
});*/
//c = new C("parameter of the constructor")
ins=new B("parameter")
console.log(ins instanceof B, ins)
ready

Revisions

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