# ztensor Benchmarks
This directory contains the scripts used to benchmark `ztensor` against other formats and to generate the performance charts found in the main `README.md` and the website.
## Prerequisites
Install the required Python dependencies:
```bash
pip install -r requirements.txt
```
## Reproducing README/Website Figures
The figures in the [README](../README.md) and [website](../website/) are generated by a standalone script that ensures consistent styling and output:
```bash
python scripts/generate_readme_charts.py
```
This reads the hardcoded benchmark data in the script and produces SVGs in `website/static/charts/`.
## Running the Benchmarks
To run the actual benchmarks and generate fresh performance data on your machine:
```bash
python bench.py
```
### Modes
- **Single Run** (default): Runs a quick benchmark with default settings.
```bash
python bench.py --size 512 --runs 5
```
- **Full Sweep**: Runs the complete suite of benchmarks (all formats, sizes, and distributions) used to gather the data for the README.
```bash
python bench.py sweep
```
This will:
1. Generate synthetic data (random and structured).
2. Benchmark write and read performance for all supported formats.
3. Save results to `bench_out/sweep_results.csv`.
4. Generate a set of analysis plots in `bench_out/plots/`.
### Updating the Charts
If you run a sweep and want to update the official README/website charts with your new data:
1. Run `python bench.py sweep` to get new numbers.
2. Update the `CROSS_FORMAT_DATA` and `WRITE_DIST_DATA` lists in `scripts/generate_readme_charts.py` with the median values from your results.
3. Run `python scripts/generate_readme_charts.py` to regenerate the SVGs.