Skip to content

Instantly share code, notes, and snippets.

@jed
Created September 26, 2010 14:06
Show Gist options
  • Save jed/597958 to your computer and use it in GitHub Desktop.
Save jed/597958 to your computer and use it in GitHub Desktop.
var max = 1000000
, fn = function fn(a,b,c,d,e){}
, jedTime
, higginsTime
, t = new Date;
for ( var i = max; i--; ) schmidt( fn );
jedTime = new Date - t;
t = new Date;
for ( var i = max; i--; ) higgins( fn );
higginsTime = new Date - t;
console.log( "schmidt: " + jedTime );
console.log( "higgins: " + higginsTime );
// schmidt: 3384
// higgins: 2001
function schmidt( fn ) {
return fn
.toString()
.split( /[^\w$]+/, fn.length + !!fn.name + 1 )
.slice( !!fn.name + 1 );
}
function higgins( fn ) {
return fn
.toString()
.replace(/function\s+\(/, "")
.split(")")[0]
.split(",");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment