Skip to content

Instantly share code, notes, and snippets.

@menxit
Last active August 22, 2018 13:39
Show Gist options
  • Save menxit/711ea4e3e59ddf15cba4c3ee493d8fa3 to your computer and use it in GitHub Desktop.
Save menxit/711ea4e3e59ddf15cba4c3ee493d8fa3 to your computer and use it in GitHub Desktop.
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