ProtoType

Benchmark created by Gary on


Setup

"use strict";
    Function.prototype.defineclass = function (base, proto) {
    
        function I() { };
        I.prototype = base.prototype;
        var v = new I;
        v.constructor = this;
        this.prototype = v;
    
        var i;
    
        if (proto instanceof Function) {
            i = {};
            proto.call(i);
        } else {
            i = proto;
        }
        for (var name in i) {
            this.prototype[name] = i[name];
            var fn = base[name] || base.prototype[name];
            if (fn) {
                this.prototype["$" + name] = fn;
            }
        }
        this.prototype["$boot"] = base.prototype.constructor;
    };
    
    function F0() {
        }
    
    function F1() {
        this.X = 0;
    }
    
    
    
    F1.defineclass(F0, { incIt: function() { this.X = this.X + 1; } });
    F1.prototype.q = function() { this.X = this.X + 1; };
    
    function F2() {
        this.$boot();
    }
    
    F2.defineclass(F1, { incIt2: function () { this.X = this.X + 1; } });
    
    var f1 = new F1();
    var f2 = new F2();

Test runner

Ready to run.

Testing in
TestOps/sec
T1
f1.incIt()
ready
t2
f2.incIt()
ready
t3
f1.q()
ready
t3
f2.q()
ready

Revisions

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

  • Revision 1: published by Gary on