Skip to content

Commit 4f4b90f

Browse files
[PR #9835/32ccfc9a backport][3.10] Adjust client payload benchmarks to better represent real world cases (#9836)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent f3dd0f9 commit 4f4b90f

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

tests/test_benchmarks_client.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ def _run() -> None:
3333
loop.run_until_complete(run_client_benchmark())
3434

3535

36-
def test_one_hundred_get_requests_with_2048_chunked_payload(
36+
def test_one_hundred_get_requests_with_1024_chunked_payload(
3737
loop: asyncio.AbstractEventLoop,
3838
aiohttp_client: AiohttpClient,
3939
benchmark: BenchmarkFixture,
4040
) -> None:
41-
"""Benchmark 100 GET requests with a small payload of 2048 bytes."""
41+
"""Benchmark 100 GET requests with a small payload of 1024 bytes."""
4242
message_count = 100
43-
payload = b"a" * 2048
43+
payload = b"a" * 1024
4444

4545
async def handler(request: web.Request) -> web.Response:
4646
resp = web.Response(body=payload)
@@ -62,14 +62,14 @@ def _run() -> None:
6262
loop.run_until_complete(run_client_benchmark())
6363

6464

65-
def test_one_hundred_get_requests_with_32768_chunked_payload(
65+
def test_one_hundred_get_requests_with_30000_chunked_payload(
6666
loop: asyncio.AbstractEventLoop,
6767
aiohttp_client: AiohttpClient,
6868
benchmark: BenchmarkFixture,
6969
) -> None:
70-
"""Benchmark 100 GET requests with a payload of 32768 bytes."""
70+
"""Benchmark 100 GET requests with a payload of 30000 bytes."""
7171
message_count = 100
72-
payload = b"a" * 32768
72+
payload = b"a" * 30000
7373

7474
async def handler(request: web.Request) -> web.Response:
7575
resp = web.Response(body=payload)
@@ -91,14 +91,14 @@ def _run() -> None:
9191
loop.run_until_complete(run_client_benchmark())
9292

9393

94-
def test_one_hundred_get_requests_with_1mib_chunked_payload(
94+
def test_one_hundred_get_requests_with_512kib_chunked_payload(
9595
loop: asyncio.AbstractEventLoop,
9696
aiohttp_client: AiohttpClient,
9797
benchmark: BenchmarkFixture,
9898
) -> None:
99-
"""Benchmark 100 GET requests with a payload of 1MiB bytes."""
99+
"""Benchmark 100 GET requests with a payload of 512KiB."""
100100
message_count = 100
101-
payload = b"a" * 1024**2
101+
payload = b"a" * (2**19)
102102

103103
async def handler(request: web.Request) -> web.Response:
104104
resp = web.Response(body=payload)
@@ -120,14 +120,14 @@ def _run() -> None:
120120
loop.run_until_complete(run_client_benchmark())
121121

122122

123-
def test_one_hundred_get_requests_with_2048_content_length_payload(
123+
def test_one_hundred_get_requests_with_1024_content_length_payload(
124124
loop: asyncio.AbstractEventLoop,
125125
aiohttp_client: AiohttpClient,
126126
benchmark: BenchmarkFixture,
127127
) -> None:
128-
"""Benchmark 100 GET requests with a small payload of 2048 bytes."""
128+
"""Benchmark 100 GET requests with a small payload of 1024 bytes."""
129129
message_count = 100
130-
payload = b"a" * 2048
130+
payload = b"a" * 1024
131131
headers = {hdrs.CONTENT_LENGTH: str(len(payload))}
132132

133133
async def handler(request: web.Request) -> web.Response:
@@ -148,14 +148,14 @@ def _run() -> None:
148148
loop.run_until_complete(run_client_benchmark())
149149

150150

151-
def test_one_hundred_get_requests_with_32768_content_length_payload(
151+
def test_one_hundred_get_requests_with_30000_content_length_payload(
152152
loop: asyncio.AbstractEventLoop,
153153
aiohttp_client: AiohttpClient,
154154
benchmark: BenchmarkFixture,
155155
) -> None:
156-
"""Benchmark 100 GET requests with a payload of 32768 bytes."""
156+
"""Benchmark 100 GET requests with a payload of 30000 bytes."""
157157
message_count = 100
158-
payload = b"a" * 32768
158+
payload = b"a" * 30000
159159
headers = {hdrs.CONTENT_LENGTH: str(len(payload))}
160160

161161
async def handler(request: web.Request) -> web.Response:
@@ -176,14 +176,14 @@ def _run() -> None:
176176
loop.run_until_complete(run_client_benchmark())
177177

178178

179-
def test_one_hundred_get_requests_with_1mib_content_length_payload(
179+
def test_one_hundred_get_requests_with_512kib_content_length_payload(
180180
loop: asyncio.AbstractEventLoop,
181181
aiohttp_client: AiohttpClient,
182182
benchmark: BenchmarkFixture,
183183
) -> None:
184-
"""Benchmark 100 GET requests with a payload of 1MiB bytes."""
184+
"""Benchmark 100 GET requests with a payload of 512KiB."""
185185
message_count = 100
186-
payload = b"a" * 1024**2
186+
payload = b"a" * (2**19)
187187
headers = {hdrs.CONTENT_LENGTH: str(len(payload))}
188188

189189
async def handler(request: web.Request) -> web.Response:

0 commit comments

Comments
 (0)