Created
December 26, 2014 18:44
-
-
Save kiichi/cd7a959b2cc2da223363 to your computer and use it in GitHub Desktop.
JavaScript Benchmark Function
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
//-------------------------------------------------------------------------------------------------- | |
// show benchmark result of function | |
// e.g. benchMe(heavyFunc,null,5) | |
function benchMe(myFunc, myArgs, cnt){ | |
if (!cnt || cnt <= 0){ | |
cnt = 1; | |
} | |
var startTime = (new Date()).getTime(); | |
for (var i=0; i<cnt; i++){ | |
myFunc(myArgs); | |
} | |
return (((new Date()).getTime()-startTime)/cnt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment