Created
November 27, 2009 18:42
-
-
Save padolsey/244166 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Run this code in any browser | |
function RegularConstructor () { | |
} | |
RegularConstructor.prototype = { | |
meth1: function(){}, | |
meth2: function(){}, | |
meth3: function(){}, | |
meth4: function(){}, | |
meth5: function(){}, | |
meth6: function(){}, | |
meth7: function(){}, | |
meth8: function(){}, | |
meth9: function(){} | |
}; | |
function crockfordsIdea () { | |
var inst = { | |
meth1: function(){}, | |
meth2: function(){}, | |
meth3: function(){}, | |
meth4: function(){}, | |
meth5: function(){}, | |
meth6: function(){}, | |
meth7: function(){}, | |
meth8: function(){}, | |
meth9: function(){} | |
}; | |
return inst; | |
} | |
var n = +new Date; | |
for (var i = 0; i < 10000; ++i ) { | |
crockfordsIdea(); | |
} | |
alert('crockfordsIdea :' + (+new Date - n) + 'ms'); | |
var n = +new Date; | |
for (var i = 0; i < 10000; ++i) { | |
new RegularConstructor(); | |
} | |
alert('RegularConstructor :' + (+new Date - n) + 'ms'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment