create

JavaScript performance comparison

Revision 2 of this test case created by pow

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    window.create0 = Object.create;
   
    window.create1 = function( p ) {
      function F() {}
      F.prototype = p;
      return new F();
    }
   
    function F() {}
   
    window.create2 = function( p ) {
      F.prototype = p;
      var o = new F();
      F.prototype = null;
      return o;
    }
   
    window.create3 = function( p ) {
      F.prototype = p;
      return new F();
    }
   
    window.Type = function() {};
    window.p = Type.prototype;
   
    window.create0w = (function() {
      var c = Object.create;
      return function( p ) {
        return c(p);
      };
    })();
};
</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
new
new Type();
pending…
Object.create
create0( p );
pending…
shim
create1( p );
pending…
optimized shim (leek-safe)
create2( p );
pending…
optimized shim (leek-unsafe)
create3( p );
pending…
wrapped Object.create
create0w( p );
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