| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,23 @@ | |||
| 1 | + """Benchmark for AsyncZeroconf.""" | ||
| 2 | + import asyncio | ||
| 3 | + import time | ||
| 4 | + | ||
| 5 | + from zeroconf.asyncio import AsyncZeroconf | ||
| 6 | + | ||
| 7 | + iterations = 10000 | ||
| 8 | + | ||
| 9 | + | ||
| 10 | + async def _create_destroy(count: int) -> None: | ||
| 11 | + for _ in range(count): | ||
| 12 | + async with AsyncZeroconf() as zc: | ||
| 13 | + await zc.zeroconf.async_wait_for_start() | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + async def _run() -> None: | ||
| 17 | + start = time.perf_counter() | ||
| 18 | + await _create_destroy(iterations) | ||
| 19 | + duration = time.perf_counter() - start | ||
| 20 | + print(f"Creating and destroying {iterations} Zeroconf instances took {duration} seconds") | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + asyncio.run(_run()) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments