Created
June 23, 2010 10:02
-
-
Save jed/449728 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var puts = require( "sys" ).puts | |
, contextFn = function( a ){ return a && this() } | |
, argFn = function( a, b ){ return b && a() } | |
, time; | |
time = +new Date; | |
for ( var i = 0; i < 10e6; i++ ) contextFn.call( contextFn, contextFn ); | |
puts( "as context: " + ( +new Date - time ) ); | |
time = +new Date; | |
for ( var i = 0; i < 10e6; i++ ) argFn( argFn, argFn ); | |
puts( "as argument: " + ( +new Date - time ) ); |
thanks, felix. your feedback is very much appreciated!
あなたは歓迎されて
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
apply
is different because it can pass a variable number of arguments which is harder to optimize for V8. I have not benchmarked it, but I suspect it to be substantially slower than justcall
.I think you should go ahead with 'this'. Everything else seems like pre-mature optimization at this point. I suspect other parts of fab to be substantially slower, so you shouldn't worry about this one for now : ).