JS inheritance test (v3)

Revision 3 of this benchmark created on


Description

Trying to test my implementation of inheritance against those two popular methods.

Preparation HTML

<script>
  MY = {};
  
  // Used for crockford inheritance
  MY.create = function(o) {
   function F() {};
   F.prototype = o;
   return new F();
  };
  
  // setup for Crockford inheritance
  MY.realbase = {
   monkey: function() {
    console.log("monkey")
   }
  }
  
  // setup for Ashkenas Inheritance
  MY.base = function() {};
  MY.base.prototype.monkey = function() {
   console.log("monkey")
  }
  
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Crockford Inheritance
window.newobject = MY.create(MY.realbase);
ready
Ashkenas Inheritance
window.newobject = new MY.base;
ready

Revisions

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