ProtoInherit

JavaScript performance comparison

Revision 4 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var inherits = function(ctor, superCtor) {
        ctor.super_ = superCtor;
        ctor.prototype = Object.create(superCtor.prototype, {
          constructor: {
            value: ctor,
            enumerable: false,
            writable: true,
            configurable: true
          }
        });
        };
   
    function Base() {
   
    }
   
    var bProto = Base.prototype;
   
    bProto.f1 = function() {};
    bProto.f2 = function() {};
    bProto.f3 = function() {};
    bProto.f4 = function() {};
   
    function Child() {}
    inherits(Child, Base);
    var cProto = Child.prototype;
   
    cProto.f5 = function() {};
    cProto.f6 = function() {};
    cProto.f7 = function() {};
    cProto.f8 = function() {};
   
    function Base1() {
      this.f1 = function() {};
      this.f2 = function() {};
      this.f3 = function() {};
      this.f4 = function() {};
    }
   
   
   
   
    function Child1() {
      this.inheritFrom = Base1;
      this.inheritFrom();
   
      this.f5 = function() {};
      this.f6 = function() {};
      this.f7 = function() {};
      this.f8 = function() {};
    }
   
   
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Proto

var c = new Child();
c.f1();
c.f2();
c.f3();
c.f4();
c.f5();
c.f6();
c.f7();
c.f8();
pending…
inherits

var c = new Child1();
c.f1();
c.f2();
c.f3();
c.f4();
c.f5();
c.f6();
c.f7();
c.f8();
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment