diff --git a/tests/test_benchmarks_http_websocket.py b/tests/test_benchmarks_http_websocket.py index ad6130a35cd..089011c4055 100644 --- a/tests/test_benchmarks_http_websocket.py +++ b/tests/test_benchmarks_http_websocket.py @@ -115,3 +115,19 @@ async def _send_one_hundred_websocket_text_messages() -> None: @benchmark def _run() -> None: loop.run_until_complete(_send_one_hundred_websocket_text_messages()) + + +def test_send_one_hundred_websocket_compressed_messages( + loop: asyncio.AbstractEventLoop, benchmark: BenchmarkFixture +) -> None: + """Benchmark sending 100 WebSocket text messages.""" + writer = WebSocketWriter(MockProtocol(loop=loop), MockTransport(), compress=15) + raw_message = b"Hello, World!" * 100 + + async def _send_one_hundred_websocket_compressed_messages() -> None: + for _ in range(100): + await writer.send_frame(raw_message, WSMsgType.BINARY) + + @benchmark + def _run() -> None: + loop.run_until_complete(_send_one_hundred_websocket_compressed_messages())