Skip to content

Commit 51145aa

Browse files
[PR #9761/50cccb38 backport][3.11] Add benchmarks for a simple POST request (#9764)
1 parent f55822e commit 51145aa

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_benchmarks_client.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,28 @@ async def run_client_benchmark() -> None:
3131
@benchmark
3232
def _run() -> None:
3333
loop.run_until_complete(run_client_benchmark())
34+
35+
36+
def test_one_hundred_simple_post_requests(
37+
loop: asyncio.AbstractEventLoop,
38+
aiohttp_client: AiohttpClient,
39+
benchmark: BenchmarkFixture,
40+
) -> None:
41+
"""Benchmark 100 simple POST requests."""
42+
message_count = 100
43+
44+
async def handler(request: web.Request) -> web.Response:
45+
return web.Response()
46+
47+
app = web.Application()
48+
app.router.add_route("POST", "/", handler)
49+
50+
async def run_client_benchmark() -> None:
51+
client = await aiohttp_client(app)
52+
for _ in range(message_count):
53+
await client.post("/", data=b"any")
54+
await client.close()
55+
56+
@benchmark
57+
def _run() -> None:
58+
loop.run_until_complete(run_client_benchmark())

0 commit comments

Comments
 (0)