Created
November 11, 2022 18:51
-
-
Save mrocklin/2908bdd3542f71e84b3100a8d37b8dfd to your computer and use it in GitHub Desktop.
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
# 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