Object.create() vs. constructor vs. object literal (v7)

Revision 7 of this benchmark created by Jeremy Ashkenas on


Preparation HTML

<script>
  Obj = function() {
   this.p = 1;
  }
  
  propObj = {
   p: {
    value: 1
   }
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Object.create() using in-place property object
o = Object.create(Object.prototype, {
 p: {
  value: 1
 }
});
ready
Object.create() using pre-defined property object
o = Object.create(Object.prototype, propObj);
ready
Constructor function
o = new Obj();
ready

Revisions

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