Created
April 11, 2009 23:51
-
-
Save furf/93784 to your computer and use it in GitHub Desktop.
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
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