Created
January 13, 2017 13:38
-
-
Save zapthedingbat/6bb85be27a8512b7ca62337e9036c1e7 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 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