Created
October 6, 2019 17:41
-
-
Save msjyoo/66d9796b78ae8127c7ef281e873a2e0d to your computer and use it in GitHub Desktop.
Event loop no-op performance test scripts
This file contains 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
let y = 0; | |
async function sleep() { | |
await new Promise(resolve => { | |
setImmediate(() => { | |
y++; | |
resolve(); | |
}); | |
}); | |
} | |
async function do_nothing() { | |
let i = 0; | |
for (i = 0; i < 10_000_000; i++) { | |
let x = await sleep(); | |
} | |
console.log(i); | |
console.log(y); | |
} | |
(async () => { | |
await do_nothing(); | |
})(); |
This file contains 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
import asyncio | |
# For uvloop | |
# import uvloop | |
# uvloop.install() | |
async def do_nothing(): | |
counter = 0 | |
while True: | |
await asyncio.sleep(0) | |
counter += 1 | |
if counter == 10_000_000: | |
return | |
async def main(): | |
await do_nothing() | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment