create

JavaScript performance comparison

Test case created

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;
   
};
</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
return new Type();
pending…
Object.create
return create0( p );
pending…
shim
return create1( p );
pending…
optimized shim (leek-safe)
return create2( p );
pending…
optimized shim (leek-unsafe)
return create3( 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