Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions bench/create_destory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Benchmark for AsyncZeroconf."""
import asyncio
import time

from zeroconf.asyncio import AsyncZeroconf

iterations = 10000


async def _create_destroy(count: int) -> None:
for _ in range(count):
async with AsyncZeroconf() as zc:
await zc.zeroconf.async_wait_for_start()


async def _run() -> None:
start = time.perf_counter()
await _create_destroy(iterations)
duration = time.perf_counter() - start
print(f"Creating and destroying {iterations} Zeroconf instances took {duration} seconds")


asyncio.run(_run())