Object.create vs Manual Inheritance

JavaScript performance comparison

Test case created and last updated

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
        function noop() { }
   
        function createObject(prototype) {
          noop.prototype = prototype;
          var result = new noop;
          noop.prototype = null;
          return result;
        }
   
        var nativeCreate = Object.create;
       
        function SuperClass() { }
        SuperClass.prototype.a = 3;
};
</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
Manual Inheritance
createObject(SuperClass.prototype);
pending…
Object.create
nativeCreate(SuperClass.prototype);
pending…

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

Compare results of other browsers

0 comments

Add a comment