@@ -120,23 +120,23 @@ def _run() -> None:
120
120
loop .run_until_complete (run_client_benchmark ())
121
121
122
122
123
- def test_five_get_requests_with_567296_compressed_chunked_payload (
123
+ def test_get_request_with_251308_compressed_chunked_payload (
124
124
loop : asyncio .AbstractEventLoop ,
125
125
aiohttp_client : AiohttpClient ,
126
126
benchmark : BenchmarkFixture ,
127
127
) -> None :
128
- """Benchmark 5 compressed GET requests with a payload of 567296 ."""
129
- message_count = 5
130
- # This payload compresses poorly to ~567296 bytes.
131
- payload = (
132
- bytes (range (0 , 256 ))
133
- + bytes ( range (255 , 0 , - 1 ) )
134
- + bytes ( range (0 , 128 ) )
135
- + bytes ( range ( 255 , 0 , - 1 ))
136
- ) * 1024
128
+ """Benchmark compressed GET requests with a payload of 251308 ."""
129
+ # This payload compresses to 251308 bytes
130
+ payload = b"" . join (
131
+ [
132
+ bytes (( * range (0 , i ), * range ( i , 0 , - 1 ) ))
133
+ for _ in range (255 )
134
+ for i in range (255 )
135
+ ]
136
+ )
137
137
138
138
async def handler (request : web .Request ) -> web .Response :
139
- resp = web .Response (body = payload )
139
+ resp = web .Response (body = payload , zlib_executor_size = 16384 )
140
140
resp .enable_compression ()
141
141
return resp
142
142
@@ -145,9 +145,8 @@ async def handler(request: web.Request) -> web.Response:
145
145
146
146
async def run_client_benchmark () -> None :
147
147
client = await aiohttp_client (app )
148
- for _ in range (message_count ):
149
- resp = await client .get ("/" )
150
- await resp .read ()
148
+ resp = await client .get ("/" )
149
+ await resp .read ()
151
150
await client .close ()
152
151
153
152
@benchmark
0 commit comments