|
1 | | -# csp benchmarks |
| 1 | +# csp-benchmarks |
2 | 2 |
|
3 | | -Benchmarks for csp |
| 3 | +Performance benchmarks for [csp](https://github.com/Point72/csp) using [airspeed velocity (ASV)](https://asv.readthedocs.io/). |
4 | 4 |
|
5 | | -[](https://github.com/csp-benchmarks/csp-benchmarks/actions/workflows/build.yaml) |
6 | | -[](https://codecov.io/gh/csp-benchmarks/csp-benchmarks) |
7 | | -[](https://github.com/csp-benchmarks/csp-benchmarks) |
8 | | -[](https://pypi.python.org/pypi/csp-benchmarks) |
| 5 | +[](https://github.com/csp-community/csp-benchmarks/actions/workflows/build.yaml) |
| 6 | +[](https://github.com/csp-community/csp-benchmarks/actions/workflows/benchmarks.yaml) |
| 7 | +[](https://github.com/csp-community/csp-benchmarks) |
9 | 8 |
|
10 | 9 | ## Overview |
11 | 10 |
|
12 | | -> [!NOTE] |
13 | | -> This library was generated using [copier](https://copier.readthedocs.io/en/stable/) from the [Base Python Project Template repository](https://github.com/python-project-templates/base). |
| 11 | +This repository contains performance benchmarks for the csp library, designed to: |
| 12 | + |
| 13 | +- Track performance over time across commits |
| 14 | +- Detect performance regressions |
| 15 | +- Compare different implementations and configurations |
| 16 | +- Run on dedicated Hetzner Cloud machines for consistent results |
| 17 | + |
| 18 | +## Benchmark Suites |
| 19 | + |
| 20 | +### Core Benchmarks (bench_core.py) |
| 21 | + |
| 22 | +- **GraphExecutionSuite**: Tests graph execution with varying node counts and tick rates |
| 23 | +- **NodeOverheadSuite**: Measures node invocation overhead |
| 24 | + |
| 25 | +### Stats Benchmarks (bench_stats.py) |
| 26 | + |
| 27 | +- **StatsBenchmarkSuite**: Tests statistical functions (median, quantile, rank) |
| 28 | +- **StatsScalingSuite**: Tests how stats scale with data size |
| 29 | + |
| 30 | +### Baselib Benchmarks (bench_baselib.py) |
| 31 | + |
| 32 | +- **BaselibSuite**: Tests built-in operations (filter, sample, delay, merge, flatten) |
| 33 | +- **CurveSuite**: Tests historical data loading |
| 34 | + |
| 35 | +### Math Benchmarks (bench_math.py) |
| 36 | + |
| 37 | +- **MathSuite**: Tests arithmetic and comparison operations |
| 38 | +- **AccumulatorSuite**: Tests accumulating operations (accum, count, diff) |
| 39 | + |
| 40 | +## Quick Start |
| 41 | + |
| 42 | +### Installation |
| 43 | + |
| 44 | +```bash |
| 45 | +# Install with development dependencies |
| 46 | +pip install -e ".[develop]" |
| 47 | + |
| 48 | +# For Hetzner Cloud integration |
| 49 | +pip install -e ".[develop,hetzner]" |
| 50 | +``` |
| 51 | + |
| 52 | +### Running Benchmarks Locally |
| 53 | + |
| 54 | +```bash |
| 55 | +# Run quick benchmarks for the current commit |
| 56 | +make benchmark-quick |
| 57 | + |
| 58 | +# Run full benchmarks |
| 59 | +make benchmark |
| 60 | + |
| 61 | +# Run using local Python environment (no virtualenv) |
| 62 | +make benchmark-local |
| 63 | + |
| 64 | +# View results |
| 65 | +make benchmark-view |
| 66 | +``` |
| 67 | + |
| 68 | +### Using ASV Directly |
| 69 | + |
| 70 | +```bash |
| 71 | +# Initialize machine configuration |
| 72 | +python -m asv machine --yes |
| 73 | + |
| 74 | +# Run benchmarks for current commit |
| 75 | +python -m asv run HEAD^! |
| 76 | + |
| 77 | +# Compare with previous commit |
| 78 | +python -m asv compare HEAD~1 HEAD |
| 79 | + |
| 80 | +# Generate and serve HTML report |
| 81 | +python -m asv publish |
| 82 | +python -m asv preview |
| 83 | +``` |
| 84 | + |
| 85 | +## Hetzner Cloud Integration |
| 86 | + |
| 87 | +For consistent benchmark results, this repository supports running benchmarks on dedicated Hetzner Cloud servers. |
| 88 | + |
| 89 | +### Setup |
| 90 | + |
| 91 | +1. Create a Hetzner Cloud API token at <https://console.hetzner.cloud/> |
| 92 | +1. Set the token as a repository secret: `HCLOUD_TOKEN` |
| 93 | +1. (Optional) Add an SSH key to Hetzner and set `HETZNER_SSH_PRIVATE_KEY` secret |
| 94 | + |
| 95 | +### Running on Hetzner |
| 96 | + |
| 97 | +```bash |
| 98 | +# Set your Hetzner token |
| 99 | +export HCLOUD_TOKEN="your-token-here" |
| 100 | + |
| 101 | +# Run benchmarks on Hetzner |
| 102 | +python -m csp_benchmarks.hetzner.cli run --push |
| 103 | + |
| 104 | +# Clean up any leftover servers |
| 105 | +python -m csp_benchmarks.hetzner.cli cleanup |
| 106 | +``` |
| 107 | + |
| 108 | +### GitHub Actions |
| 109 | + |
| 110 | +Benchmarks run automatically: |
| 111 | + |
| 112 | +- **Weekly**: Full benchmarks on Hetzner Cloud (Sunday 2 AM UTC) |
| 113 | +- **On push to main**: Benchmarks for the new commit |
| 114 | +- **Manual trigger**: Via workflow_dispatch with custom options |
| 115 | + |
| 116 | +## Configuration |
| 117 | + |
| 118 | +The ASV configuration is in `asv.conf.json`. Key settings: |
| 119 | + |
| 120 | +```json |
| 121 | +{ |
| 122 | + "project": "csp", |
| 123 | + "repo": "https://github.com/Point72/csp.git", |
| 124 | + "branches": ["main"], |
| 125 | + "pythons": ["3.11"], |
| 126 | + "benchmark_dir": "benchmarks", |
| 127 | + "results_dir": "results" |
| 128 | +} |
| 129 | +``` |
| 130 | + |
| 131 | +## Results |
| 132 | + |
| 133 | +Benchmark results are stored in the `results/` directory and published to GitHub Pages. |
| 134 | + |
| 135 | +View the latest results at: <https://csp-community.github.io/csp-benchmarks/benchmarks/> |
| 136 | + |
| 137 | +## Contributing |
| 138 | + |
| 139 | +1. Add new benchmarks to the `benchmarks/` directory |
| 140 | +1. Follow ASV naming conventions (`bench_*.py`, class names ending in `Suite`) |
| 141 | +1. Use parameterized benchmarks for testing across different configurations |
| 142 | +1. Run `make benchmark-local` to test your benchmarks before submitting |
0 commit comments