dalf / pyhttp-benchmark

Micro-benchmarks of the Python http clients. Heavily inspired by httpxprof.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pyhttp-benchmark

Micro-benchmarks of the Python HTTP clients. Heavily inspired by httpxprof.

Each test runs inside a new spawn process with garbage collector stopped. Use time.perf_counter() and time.process_time().

See:

The HTTPS server uses:

Usage

In a virtualenv:

# install
pip install -e git+https://github.com/dalf/pyhttp-benchmark#egg=pyhttpbenchmark

# or if you want to use --png option (see below), add the graph extra:
# pip install -e git+https://github.com/dalf/pyhttp-benchmark#egg=pyhttpbenchmark[graph]

# install shell completion
eval "$(_PYHTTPBENCHMARK_COMPLETE=source_bash pyhttpbenchmark )"

# run all cases, all scenarios
# output in the current directory
# it can be changed with the --output parameter
pyhttpbenchmark run . .

See the output.

# display available cases and scenarios
pyhttpbenchmark show cases
pyhttpbenchmark show scenarios

# run some cases and some scenarios
pyhttpbenchmark run httpx_uvloop s100_1_0,p60_1024_5

# run one case with one scenario
# record .prof, .csv files and create graph store as .png file (require matplotlib)
pyhttpbenchmark run --png --csv --profile httpcore_uvloop s100_1_0

# view .prof file using snakeviz
pyhttpbenchmark view httpcore_uvloop_anyio_http2 s100_1_0

# custom cases
wget https://gist.githubusercontent.com/dalf/cebb2032578151357b8c9ab2a320b51f/raw/dab40e925ced12738cc6f69c61b43a2d20f0c509/httpx_trio.py
wget https://gist.githubusercontent.com/dalf/cebb2032578151357b8c9ab2a320b51f/raw/7dbc414f53034d256f8063fc9da21dc94eefb65f/httpx_hack.py
cat httpx_trio.py
cat httpx_hack.py
pyhttpbenchmark run --tries 4 --profile ./httpx_trio.py,./httpx_hack.py,httpx,aiohttp 1_100seq_1mb
pyhttpbenchmark view ./httpx_hack.py 1_100seq_1mb

About

Micro-benchmarks of the Python http clients. Heavily inspired by httpxprof.

License:GNU Affero General Public License v3.0


Languages

Language:Python 100.0%