Created
February 11, 2014 14:38
-
-
Save juanfrnz/8936009 to your computer and use it in GitHub Desktop.
Measure average execution time for functions.
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
Function.prototype.avg = function() { | |
var avg = 0; | |
var r = 5; | |
for (var i = 0; i < r; i++) { | |
var begin = new Date(); | |
this.apply(this, arguments); | |
avg += (new Date() - begin); | |
} | |
return avg / r; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment