mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
[sans-io] add minimal benchmarks
This commit is contained in:
parent
dd723c733e
commit
decd2b8c80
42
test/mitmproxy/proxy2/bench.py
Normal file
42
test/mitmproxy/proxy2/bench.py
Normal file
@ -0,0 +1,42 @@
|
||||
"""
|
||||
Usage:
|
||||
- pip install pytest-benchmark
|
||||
- pytest bench.py
|
||||
|
||||
See also:
|
||||
- https://github.com/mitmproxy/proxybench
|
||||
"""
|
||||
import copy
|
||||
|
||||
from .layers.http import test_http, test_http2
|
||||
from .layers import test_tcp, test_tls
|
||||
|
||||
|
||||
def test_bench_http_roundtrip(tctx, benchmark):
|
||||
# benchmark something
|
||||
benchmark(test_http.test_http_proxy, tctx)
|
||||
|
||||
|
||||
def test_bench_http2_roundtrip(tctx, benchmark):
|
||||
# benchmark something
|
||||
benchmark(test_http2.test_simple, tctx)
|
||||
|
||||
|
||||
def test_bench_tcp_roundtrip(tctx, benchmark):
|
||||
# benchmark something
|
||||
benchmark(lambda: test_tcp.test_simple(copy.deepcopy(tctx)))
|
||||
|
||||
|
||||
def test_bench_server_tls(tctx, benchmark):
|
||||
t = test_tls.TestServerTLS().test_simple
|
||||
benchmark(lambda: t(copy.deepcopy(tctx)))
|
||||
|
||||
|
||||
def test_bench_client_tls(tctx, benchmark):
|
||||
t = test_tls.TestClientTLS().test_client_only
|
||||
benchmark(lambda: t(copy.deepcopy(tctx)))
|
||||
|
||||
|
||||
def test_bench_tls_both(tctx, benchmark):
|
||||
t = test_tls.TestClientTLS().test_server_required
|
||||
benchmark(lambda: t(copy.deepcopy(tctx)))
|
Loading…
Reference in New Issue
Block a user