Skip to content

Instantly share code, notes, and snippets.

@miketaylr
Forked from brianjlandau/jquery.benchmark.js
Created December 8, 2009 18:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miketaylr/251889 to your computer and use it in GitHub Desktop.
Save miketaylr/251889 to your computer and use it in GitHub Desktop.
// based on methodology developed by PPK:
// http://www.quirksmode.org/blog/archives/2009/08/when_to_read_ou.html
(function($){
$.benchmark = function(times, result_selector, func){
var startTime = new Date().getTime();
while (times != 0){
func();
times--;
}
setTimeout(function () {
var endTime = new Date().getTime();
var result = (endTime-startTime)/1000;
$(result_selector).html(result);
},10);
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment