new vs Object.create (v17)

Revision 17 of this benchmark created by tdgcummings on


Preparation HTML

<script>
  var Klass = function() {};
  
  Klass.prototype.a = function() {};
  Klass.prototype.b = function() {};
  Klass.prototype.c = function() {};

  var count = 10240;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
new
for (var i = 0; i < count; i++) {
  var object = new Klass();
  if (!object)
    throw new Error();
}
ready
Object.create
for (var i = 0; i < count; i++) {
  var object = Object.create(Klass.prototype);
  if (!object)
    throw new Error();
}
ready

Revisions

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