Skip to content

Commit

Permalink
[PR #9900/7180ea8e backport][3.10] Add benchmark for a route that sup…
Browse files Browse the repository at this point in the history
…ports multiple methods (#9901)
  • Loading branch information
patchback[bot] authored Nov 15, 2024
1 parent caaf21b commit d4acbd6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_benchmarks_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,34 @@ def _run() -> None:
loop.run_until_complete(run_client_benchmark())


def test_one_hundred_simple_get_requests_multiple_methods_route(
loop: asyncio.AbstractEventLoop,
aiohttp_client: AiohttpClient,
benchmark: BenchmarkFixture,
) -> None:
"""Benchmark 100 simple GET requests on a route with multiple methods."""
message_count = 100

async def handler(request: web.Request) -> web.Response:
return web.Response()

app = web.Application()
# GET intentionally registered last to ensure time complexity
# of the route lookup is benchmarked
for method in ("DELETE", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "GET"):
app.router.add_route(method, "/", handler)

async def run_client_benchmark() -> None:
client = await aiohttp_client(app)
for _ in range(message_count):
await client.get("/")
await client.close()

@benchmark
def _run() -> None:
loop.run_until_complete(run_client_benchmark())


def test_one_hundred_get_requests_with_1024_chunked_payload(
loop: asyncio.AbstractEventLoop,
aiohttp_client: AiohttpClient,
Expand Down

0 comments on commit d4acbd6

Please sign in to comment.