Created
September 26, 2010 14:06
-
-
Save jed/597958 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
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