@@ -33,6 +33,87 @@ def _run() -> None:
33
33
loop .run_until_complete (run_client_benchmark ())
34
34
35
35
36
+ def test_one_hundred_get_requests_with_2048_payload (
37
+ loop : asyncio .AbstractEventLoop ,
38
+ aiohttp_client : AiohttpClient ,
39
+ benchmark : BenchmarkFixture ,
40
+ ) -> None :
41
+ """Benchmark 100 GET requests with a small payload of 2048 bytes."""
42
+ message_count = 100
43
+ payload = b"a" * 2048
44
+
45
+ async def handler (request : web .Request ) -> web .Response :
46
+ return web .Response (body = payload )
47
+
48
+ app = web .Application ()
49
+ app .router .add_route ("GET" , "/" , handler )
50
+
51
+ async def run_client_benchmark () -> None :
52
+ client = await aiohttp_client (app )
53
+ for _ in range (message_count ):
54
+ resp = await client .get ("/" )
55
+ await resp .read ()
56
+ await client .close ()
57
+
58
+ @benchmark
59
+ def _run () -> None :
60
+ loop .run_until_complete (run_client_benchmark ())
61
+
62
+
63
+ def test_one_hundred_get_requests_with_32768_payload (
64
+ loop : asyncio .AbstractEventLoop ,
65
+ aiohttp_client : AiohttpClient ,
66
+ benchmark : BenchmarkFixture ,
67
+ ) -> None :
68
+ """Benchmark 100 GET requests with a payload of 32768 bytes."""
69
+ message_count = 100
70
+ payload = b"a" * 32768
71
+
72
+ async def handler (request : web .Request ) -> web .Response :
73
+ return web .Response (body = payload )
74
+
75
+ app = web .Application ()
76
+ app .router .add_route ("GET" , "/" , handler )
77
+
78
+ async def run_client_benchmark () -> None :
79
+ client = await aiohttp_client (app )
80
+ for _ in range (message_count ):
81
+ resp = await client .get ("/" )
82
+ await resp .read ()
83
+ await client .close ()
84
+
85
+ @benchmark
86
+ def _run () -> None :
87
+ loop .run_until_complete (run_client_benchmark ())
88
+
89
+
90
+ def test_one_hundred_get_requests_with_1mib_payload (
91
+ loop : asyncio .AbstractEventLoop ,
92
+ aiohttp_client : AiohttpClient ,
93
+ benchmark : BenchmarkFixture ,
94
+ ) -> None :
95
+ """Benchmark 100 GET requests with a payload of 1MiB bytes."""
96
+ message_count = 100
97
+ payload = b"a" * 1024 ** 2
98
+
99
+ async def handler (request : web .Request ) -> web .Response :
100
+ return web .Response (body = payload )
101
+
102
+ app = web .Application ()
103
+ app .router .add_route ("GET" , "/" , handler )
104
+
105
+ async def run_client_benchmark () -> None :
106
+ client = await aiohttp_client (app )
107
+ for _ in range (message_count ):
108
+ resp = await client .get ("/" )
109
+ await resp .read ()
110
+ await client .close ()
111
+
112
+ @benchmark
113
+ def _run () -> None :
114
+ loop .run_until_complete (run_client_benchmark ())
115
+
116
+
36
117
def test_one_hundred_simple_post_requests (
37
118
loop : asyncio .AbstractEventLoop ,
38
119
aiohttp_client : AiohttpClient ,
0 commit comments