Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HttPyBench - Benchmark your HTTP applications response times

Description

A simple yet customisable CLI-based python script to benchmark cURL commands to your web applications. Uses uncurl to parse cURL commands to python requests.

Pass a file containing a cURL command as an argument, and the script will handle the rest. If omitted, it will use the value stored in your clipboard.

Installation

Install as a global command with uv (or pipx, same syntax):

$ git clone git@github.com:arnegiacomo/HttPyBench.git
$ cd HttPyBench
$ uv tool install .

This installs httpybench into an isolated environment with all dependencies and puts it on your PATH, so it can be run from anywhere. To uninstall, run uv tool uninstall httpybench.

Example

$ httpybench example_curl.txt

Result:

+-----------------+-------------------------+------------------------+-------------------------+-------------------------+-------------------+-------------------+------------------------+----------------+
| Thread Name     | Average response time   | Median response time   | Fastest response time   | Slowest response time   | 95th percentile   | 99th percentile   |   Successful responses | Success rate   |
+=================+=========================+========================+=========================+=========================+===================+===================+========================+================+
| Worker thread 0 | 2ms                     | 1ms                    | 1ms                     | 6ms                     | 6ms               | 6ms               |                     10 | 100.00%        |
+-----------------+-------------------------+------------------------+-------------------------+-------------------------+-------------------+-------------------+------------------------+----------------+

Usage

$ httpybench --help
 Usage: httpybench [OPTIONS] [file]

╭─ Arguments ──────────────────────────────────────────────────────────────────╮
│   file      <filename>  Path to file containing a cURL command to run. Will  │
│                         use clipboard value if not provided. Must only       │
│                         contain a single valid cURL command!                 │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────╮
│ --requests       -r      <int range> [x>=1]  Number of times to run cURL     │
│                                              command on each worker thread.  │
│                                              [default: 10]                   │
│ --threads        -t      <int range> [x>=1]  Number of worker threads to run │
│                                              cURL commands in parallel.      │
│                                              [default: 1]                    │
│ --delay          -d      <int range> [x>=0]  Delay between creation of       │
│                                              worker threads.                 │
│                                              [default: 0]                    │
│ --request_delay          <int range> [x>=0]  Number of seconds to sleep      │
│                                              between cURL commands.          │
│                                              [default: 5]                    │
│ --timeout                <int range> [x>=1]  Number of seconds to wait for a │
│                                              response before timing out.     │
│                                              [default: 30]                   │
│ --savefile       -s      <str>               File to save results in json    │
│                                              format. Results will not be     │
│                                              saved if omitted.               │
│ --proxy          -p      <str>               Proxy to route requests         │
│                                              through, e.g. localhost:9999.   │
│                                              Scheme defaults to http:// if   │
│                                              omitted.                        │
│ --insecure       -k                          Skip TLS certificate            │
│                                              verification, e.g. when         │
│                                              benchmarking through an         │
│                                              intercepting proxy.             │
│ --help           -h                          Show this message and exit.     │
╰──────────────────────────────────────────────────────────────────────────────╯

Proxying and TLS

Route requests through a proxy (e.g. mitmproxy) with --proxy localhost:9999. If the proxy intercepts TLS, certificate verification will fail - either skip verification with --insecure, or keep it and trust the proxy's CA certificate instead:

$ httpybench example_curl.txt --proxy localhost:9999 --insecure
$ REQUESTS_CA_BUNDLE=~/.mitmproxy/mitmproxy-ca-cert.pem httpybench example_curl.txt --proxy localhost:9999

Development

Tests run in CI on every push. To run them locally:

$ uv run pytest

This creates a .venv with the project and dev dependencies installed, so no manual setup is needed. uv run httpybench always runs the working tree, while the globally installed command is a snapshot - refresh it after changes with:

$ uv tool install . --reinstall

Disclaimer

This is not meant as a Denial Of Service tool, it would be a pretty bad one at that... It's basically meant to be an easy-to-use tool to benchmark endpoints for your applications, e.g. for testing your REST-API endpoints, either locally or deployed.

About

A simple yet customisable CLI-based python script to benchmark cURL commands to your web applications.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages