Skip to content

Instantly share code, notes, and snippets.

@furf
Created April 11, 2009 23:51
Show Gist options
  • Save furf/93784 to your computer and use it in GitHub Desktop.
Save furf/93784 to your computer and use it in GitHub Desktop.
var stress = function(fn, iterations) {
iterations = iterations || 1;
var result;
var start = new Date();
for (var i = 0; i < iterations; ++i) {
result = fn();
};
var end = new Date();
var total = end - start;
var average = total / iterations;
return {
iterations: iterations,
total: total + 'ms',
average: average + 'ms',
result: result
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment