Skip to content

Commit 55c5f1f

Browse files
authored
Add benchmark for JSON post requests that check the content type (#10553)
1 parent e507ba3 commit 55c5f1f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_benchmarks_client.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,3 +319,30 @@ async def run_client_benchmark() -> None:
319319
@benchmark
320320
def _run() -> None:
321321
loop.run_until_complete(run_client_benchmark())
322+
323+
324+
def test_one_hundred_json_post_requests(
325+
loop: asyncio.AbstractEventLoop,
326+
aiohttp_client: AiohttpClient,
327+
benchmark: BenchmarkFixture,
328+
) -> None:
329+
"""Benchmark 100 JSON POST requests that check the content-type."""
330+
message_count = 100
331+
332+
async def handler(request: web.Request) -> web.Response:
333+
_ = request.content_type
334+
_ = request.charset
335+
return web.Response()
336+
337+
app = web.Application()
338+
app.router.add_route("POST", "/", handler)
339+
340+
async def run_client_benchmark() -> None:
341+
client = await aiohttp_client(app)
342+
for _ in range(message_count):
343+
await client.post("/", json={"key": "value"})
344+
await client.close()
345+
346+
@benchmark
347+
def _run() -> None:
348+
loop.run_until_complete(run_client_benchmark())

0 commit comments

Comments
 (0)