Skip to content

Instantly share code, notes, and snippets.

@zapthedingbat
Created January 13, 2017 13:38
Show Gist options
  • Select an option

  • Save zapthedingbat/6bb85be27a8512b7ca62337e9036c1e7 to your computer and use it in GitHub Desktop.

Select an option

Save zapthedingbat/6bb85be27a8512b7ca62337e9036c1e7 to your computer and use it in GitHub Desktop.
const runs = 10;
function run(method, runIndex) {
console.time(`run ${runIndex}`);
return method().then(() => {
console.timeEnd(`run ${runIndex}`);
if (runIndex < runs){
return run(method, runIndex+1);
}
});
}
console.time('runs');
return run(() => {
// Long running promise E.g:
return new Promise((resolve, reject) => { setTimeout(resolve, 1000); });
}, 0)
.then(() => { console.timeEnd('runs'); })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment