Skip to content

Instantly share code, notes, and snippets.

@mrocklin
Created November 11, 2022 18:51
Show Gist options
  • Save mrocklin/2908bdd3542f71e84b3100a8d37b8dfd to your computer and use it in GitHub Desktop.
Save mrocklin/2908bdd3542f71e84b3100a8d37b8dfd to your computer and use it in GitHub Desktop.
# pip install dask[complete]
from dask.distributed import Client, Worker, Scheduler, wait
def inc(x):
return x + 1
async def benchmark():
async with Scheduler() as scheduler:
async with Worker(scheduler.address):
async with Client(scheduler.address, asynchronous=True) as client:
futures = client.map(inc, range(1000))
for _ in range(10):
futures = client.map(inc, futures)
await wait(futures)
import asyncio
asyncio.get_event_loop().run_until_complete(benchmark())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment