|
| 1 | +# 🏎️ Benchmark for pyproxy |
| 2 | + |
| 3 | +This benchmarking tool is designed to measure the performance of **pyproxy** in handling HTTP and HTTPS requests. It allows you to compare the average, maximum, and minimum request times both with and without the proxy. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 📦 **Installation** |
| 8 | + |
| 9 | +### Install dependencies |
| 10 | +Before running the benchmark, you need to install the required dependencies. You can do so by running the following command: |
| 11 | +```bash |
| 12 | +pip install -r benchmark/requirements.txt |
| 13 | +``` |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## 🚀 **Usage** |
| 18 | + |
| 19 | +### Start the Proxy |
| 20 | +Before running the benchmark, ensure that **pyproxy** is running. Start the proxy by running: |
| 21 | +```bash |
| 22 | +python3 -m pyproxy |
| 23 | +``` |
| 24 | +The proxy will be available at `0.0.0.0:8080`. |
| 25 | + |
| 26 | +### Run the benchmark |
| 27 | +Once the proxy is up and running, execute the following command from the root of the project to start the benchmark: |
| 28 | +```bash |
| 29 | +python3 benchmark/benchmark.py --target-file benchmark/urls.txt |
| 30 | +``` |
| 31 | + |
| 32 | +This will run the benchmark using the URLs listed in `benchmark/urls.txt` and generate a report on the request times, comparing the proxy performance (with and without the proxy). |
| 33 | + |
| 34 | +### Customizing the URLs and Requests |
| 35 | + |
| 36 | +- You can modify the `benchmark/urls.txt` file to add multiple URLs that you want to benchmark. Each line should contain a URL. |
| 37 | + |
| 38 | +- Alternatively, you can test a single URL by using the `--target-url` argument. For example: |
| 39 | + ```bash |
| 40 | + python3 benchmark/benchmark.py --target-url http://example.com |
| 41 | + ``` |
| 42 | + |
| 43 | +- You can also change the number of requests made during the benchmark using the `--num-requests` argument. By default, it tests 100 requests per URL, but you can adjust it like this: |
| 44 | + ```bash |
| 45 | + python3 benchmark/benchmark.py --target-file benchmark/urls.txt --num-requests 50 |
| 46 | + ``` |
| 47 | + This will test 50 requests per URL instead of the default 10. |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## 📊 **Benchmark Results** |
| 52 | + |
| 53 | +The benchmarking script will produce a table comparing the average, maximum, and minimum request times for each URL, as well as a breakdown into the following columns: |
| 54 | + |
| 55 | +- **With Proxy**: |
| 56 | + - **Avg**: Average request time with the proxy. |
| 57 | + - **Max**: Maximum request time with the proxy. |
| 58 | + - **Min**: Minimum request time with the proxy. |
| 59 | + |
| 60 | +- **Without Proxy**: |
| 61 | + - **Avg**: Average request time without the proxy. |
| 62 | + - **Max**: Maximum request time without the proxy. |
| 63 | + - **Min**: Minimum request time without the proxy. |
| 64 | + |
| 65 | +The detailed report will be available in the `outputs` directory as a file named `benchmark_combined_report_<timestamp>.html`. You can open this HTML file in a browser to view the results. |
| 66 | + |
| 67 | +## 📈 **Example Benchmark Results** |
| 68 | + |
| 69 | +### Global Proxy Performance Summary |
| 70 | + |
| 71 | +| **Metric** | **Value** | |
| 72 | +|--------------------------------------|--------------------| |
| 73 | +| Global average without proxy | 0.341067 seconds | |
| 74 | +| Global average with proxy | 0.414619 seconds | |
| 75 | +| Impact (Slowdown) | 21.57% | |
| 76 | + |
| 77 | +### Benchmark Results Summary |
| 78 | + |
| 79 | +| **URL** | **Avg (s)** | **Min (s)** | **Max (s)** | **Avg with Proxy (s)** | **Min with Proxy (s)** | **Max with Proxy (s)** | |
| 80 | +|-----------------------|-------------|-------------|-------------|-------------------------|-------------------------|-------------------------| |
| 81 | +| `http://example.com` | 0.24766 | 0.19376 | 0.30262 | 0.27064 | 0.19926 | 0.30419 | |
| 82 | +| `https://example.com` | 0.43447 | 0.33968 | 0.48372 | 0.55860 | 0.41271 | 0.67175 | |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +### Example Reports |
| 87 | + |
| 88 | +Example reports can be found in the following files: |
| 89 | +- [Interactive Report Example](outputs/benchmark_combined_interactive_example.html) |
| 90 | +- [Report Example](outputs/benchmark_combined_report_example.html) |
| 91 | + |
| 92 | +These files contain example benchmark results and interactive graphs. |
| 93 | + |
| 94 | +--- |
0 commit comments