asyncio:
import time import asyncio REPS = 1_000_000 async def coro(): for i in range(REPS): await asyncio.sleep(0) t0 = time.perf_counter() asyncio.run(coro()) dt = time.perf_counter() - t0 print(REPS / dt, 'reps/s')
asynker (https://github.com/enkore/asynker):
import time import asynker REPS = 1_000_000 async def coro(): for i in range(REPS): await asynker.suspend() t0 = time.perf_counter() sched = asynker.Scheduler() sched.run_until_complete(coro()) dt = time.perf_counter() - t0 print(REPS / dt, 'reps/s')
The excellent curio (https://github.com/dabeaz/curio):
import time import curio REPS = 1_000_000 async def coro(): for i in range(REPS): await curio.sleep(0) t0 = time.perf_counter() curio.run(coro()) dt = time.perf_counter() - t0 print(REPS / dt, 'reps/s')
Not that this number is hugely important.
https://github.com/MagicStack/uvloop
(The number's 500k)
asyncio:
~180kasynker (https://github.com/enkore/asynker):
~900kThe excellent curio (https://github.com/dabeaz/curio):
~180kNot that this number is hugely important.