Last active
August 22, 2018 13:39
-
-
Save menxit/711ea4e3e59ddf15cba4c3ee493d8fa3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const test = (name, foo, measures = [10, 100, 1000, 10000, 100000, 1000000]) => { | |
console.log(name); | |
measures.forEach(async n => { | |
const start = new Date(); | |
await Promise.all(new Array(n).fill(1).map(() => foo)); | |
const end = new Date(); | |
const time = end.getTime() - start.getTime(); | |
console.log(`${n} requests`); | |
console.log(` Total time: ${time/1000} s`); | |
console.log(` Average time: ${time/n} ms`); | |
console.log("============================\n"); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment