Created
October 2, 2016 05:05
-
-
Save spac3unit/2524d742422d7ebbea8475e481176788 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
function bench(method, args, description) { | |
var start, duration, | |
max = Number.MIN_VALUE, | |
min = Number.MAX_VALUE, | |
average = 0; | |
for(var i = 0; i< 10; i++) { | |
start = Date.now(); | |
var index = method(args); | |
duration = Date.now() - start; | |
max = Math.max(max, duration); | |
min = Math.min(min, duration); | |
average += duration; | |
} | |
console.log('%s: average=%dms, min = %dms, max = %dms', description, average/10.0, min, max); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment