File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -319,3 +319,30 @@ async def run_client_benchmark() -> None:
319
319
@benchmark
320
320
def _run () -> None :
321
321
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 ())
You can’t perform that action at this time.
0 commit comments