Skip to content

Commit

Permalink
[PR #9799/d40b1839 backport][3.11] Add compressed WebSocketWriter ben…
Browse files Browse the repository at this point in the history
…chmark (#9802)

Co-authored-by: J. Nick Koston <[email protected]>
  • Loading branch information
patchback[bot] and bdraco authored Nov 11, 2024
1 parent c6270f2 commit 2490e4a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_benchmarks_http_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 compressed 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())

0 comments on commit 2490e4a

Please sign in to comment.