Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmark for sending compressed payload with chunks #9840

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/test_benchmarks_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,41 @@ def _run() -> None:
loop.run_until_complete(run_client_benchmark())


def test_five_get_requests_with_567296_compressed_chunked_payload(
loop: asyncio.AbstractEventLoop,
aiohttp_client: AiohttpClient,
benchmark: BenchmarkFixture,
) -> None:
"""Benchmark 5 compressed GET requests with a payload of 567296."""
message_count = 5
# This payload compresses poorly to ~567296 bytes.
payload = (
bytes(range(0, 256))
+ bytes(range(255, 0, -1))
+ bytes(range(0, 128))
+ bytes(range(255, 0, -1))
) * 1024
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test was bad on this. The payload isn't actually large enough


async def handler(request: web.Request) -> web.Response:
resp = web.Response(body=payload)
resp.enable_compression()
return resp

app = web.Application()
app.router.add_route("GET", "/", handler)

async def run_client_benchmark() -> None:
client = await aiohttp_client(app)
for _ in range(message_count):
resp = await client.get("/")
await resp.read()
await client.close()

@benchmark
def _run() -> None:
loop.run_until_complete(run_client_benchmark())


def test_one_hundred_get_requests_with_1024_content_length_payload(
loop: asyncio.AbstractEventLoop,
aiohttp_client: AiohttpClient,
Expand Down
Loading