Skip to content

Commit e5917cd

Browse files
[PR #9844/fabf3884 backport][3.10] Fix compressed get request benchmark payload length (#9845)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent 68a1f42 commit e5917cd

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

tests/test_benchmarks_client.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -120,23 +120,23 @@ def _run() -> None:
120120
loop.run_until_complete(run_client_benchmark())
121121

122122

123-
def test_five_get_requests_with_567296_compressed_chunked_payload(
123+
def test_get_request_with_251308_compressed_chunked_payload(
124124
loop: asyncio.AbstractEventLoop,
125125
aiohttp_client: AiohttpClient,
126126
benchmark: BenchmarkFixture,
127127
) -> 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+
)
137137

138138
async def handler(request: web.Request) -> web.Response:
139-
resp = web.Response(body=payload)
139+
resp = web.Response(body=payload, zlib_executor_size=16384)
140140
resp.enable_compression()
141141
return resp
142142

@@ -145,9 +145,8 @@ async def handler(request: web.Request) -> web.Response:
145145

146146
async def run_client_benchmark() -> None:
147147
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()
151150
await client.close()
152151

153152
@benchmark

0 commit comments

Comments
 (0)