Skip to content

Instantly share code, notes, and snippets.

@bga
Created April 25, 2010 13:25
Show Gist options
  • Save bga/378405 to your computer and use it in GitHub Desktop.
Save bga/378405 to your computer and use it in GitHub Desktop.
/* tnx @kangax for idea */
var i, n = 400000,
_fn = function(){}, that = {}, args = [];
console.time("call");
i = n; while(i--)
{
_fn.call(that);
}
console.timeEnd("call");
console.time("apply");
i = n; while(i--)
{
_fn.apply(that, args);
}
console.timeEnd("apply");
/*
opera 10.51
call: 809
apply: 968
apply: 1069
call: 735
ff 3.6
call: 1371
apply: 1426
apply: 1421
call: 1274
chrome 4
call: 1064
apply: 1178
apply: 1312
call: 922
ie7 n/=5
call: 781
apply: 1012
apply: 1022
call: 711
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment