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

[PR #9799/d40b1839 backport][3.11] Add compressed WebSocketWriter benchmark #9802

Merged
Changes from 1 commit
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
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 text messages."""
bdraco marked this conversation as resolved.
Show resolved Hide resolved
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())
Loading