Skip to content

Instantly share code, notes, and snippets.

@msjyoo
Created October 6, 2019 17:41
Show Gist options
  • Save msjyoo/66d9796b78ae8127c7ef281e873a2e0d to your computer and use it in GitHub Desktop.
Save msjyoo/66d9796b78ae8127c7ef281e873a2e0d to your computer and use it in GitHub Desktop.
Event loop no-op performance test scripts
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();
})();
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