Skip to content

Instantly share code, notes, and snippets.

@juanfrnz
Created February 11, 2014 14:38
Show Gist options
  • Save juanfrnz/8936009 to your computer and use it in GitHub Desktop.
Save juanfrnz/8936009 to your computer and use it in GitHub Desktop.
Measure average execution time for functions.
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