create-vs-constructor (v2)

Revision 2 of this benchmark created by foo on


Preparation HTML

<script>
 var Constructor;
</script>

Setup

var Constructor = function ConstructorName() { this.a = 1; }

Test runner

Ready to run.

Testing in
TestOps/sec
func
function F(){}
F.prototype = Constructor.prototype;
return new F();
ready
Object.create
return Object.create(Constructor.prototype);
ready
cached func
var f = Constructor.$$cachedConstruct;
if (!f) {
  f = Constructor.$$cachedConstruct = function F(){};
  f.prototype = Constructor.prototype;
}
return new f();
ready

Revisions

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