Skip to content

Commit 377a1f8

Browse files
[PR #10730/0b9d3571 backport][3.11] Add benchmarks for large binary WebSocket message roundtrips (#10731)
Co-authored-by: J. Nick Koston <[email protected]>
1 parent 98add82 commit 377a1f8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/test_benchmarks_client_ws.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44

5+
import pytest
56
from pytest_codspeed import BenchmarkFixture
67

78
from aiohttp import web
@@ -40,19 +41,22 @@ def _run() -> None:
4041
loop.run_until_complete(run_websocket_benchmark())
4142

4243

44+
@pytest.mark.parametrize("msg_size", [6, MSG_SIZE * 4], ids=["small", "large"])
4345
def test_one_thousand_round_trip_websocket_binary_messages(
4446
loop: asyncio.AbstractEventLoop,
4547
aiohttp_client: AiohttpClient,
4648
benchmark: BenchmarkFixture,
49+
msg_size: int,
4750
) -> None:
4851
"""Benchmark round trip of 1000 WebSocket binary messages."""
4952
message_count = 1000
53+
raw_message = b"x" * msg_size
5054

5155
async def handler(request: web.Request) -> web.WebSocketResponse:
5256
ws = web.WebSocketResponse()
5357
await ws.prepare(request)
5458
for _ in range(message_count):
55-
await ws.send_bytes(b"answer")
59+
await ws.send_bytes(raw_message)
5660
await ws.close()
5761
return ws
5862

0 commit comments

Comments
 (0)