Object.create vs Crockford vs Constructor (v25)

Revision 25 of this benchmark created on


Preparation HTML

<script>
  var sharedPrototype = {
   one: function() {
    return 1;
   },
   two: function() {
    return 2;
   },
   three: function() {
    return 3;
   }
  };
  
  var ObjectCheckCreate = function(proto) {
    for(var o in proto){
      if(o == 'check')
        continue;
    }
    Object.create(sharedPrototype);
  };
  
  var extend = function(prototype){
    var obj = {};
    for(var c in prototype)
      obj[c] = function(){
        prototype[c].call(window, 'new args');
      }
    return obj;
  }
  
  var Constructor = function() {};
  Constructor.prototype = sharedPrototype;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Object.create()
var i = 100;
while (i--) Object.create(sharedPrototype);
ready
Object Extend with function rebinding
var i = 100;
while (i--) extend(sharedPrototype);
ready
Constructor
var i = 100;
while (i--) new Constructor;
ready

Revisions

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