Object.create vs. new

JavaScript performance comparison

Revision 27 of this test case created by Shane Holloway

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  function asNewable(proto) {
    function C() {}
    C.prototype = proto
    return C;
  }
  
  const base_proto = {
      method_one() { return 'one' }
    , *gen_two() { yield 'two'; yield 'two' }
    , get prop() { return 'prop' }
  }
  
  const Newable = asNewable(base_proto)

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Object.create(base_proto)
var ans = Object.create(base_proto)
pending…

Revisions

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

0 Comments