Last active
February 8, 2022 07:40
-
-
Save iMichaelOwolabi/43239f14d184d62db3de9c81d3c0c68e to your computer and use it in GitHub Desktop.
Sample use of blocking promise implementation in Node.js
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
// Do not do this since the awaits are not related in any way but are blocking ⛔️ | |
const blockingAsnycFunction = async () => { | |
// Start recording the execution time of the following code. | |
console.time('blocking-await'); | |
const promiseResult1 = await samplePromise1(); | |
const promiseResult2 = await samplePromise2(); | |
console.log(promiseResult1); | |
console.log(promiseResult2); | |
// Stop recording the execution time and log the elapsed time to the console. | |
console.timeEnd('blocking-await'); | |
}; | |
blockingAsnycFunction(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment