Spaces:
Build error
Build error
Download headroom/cli/perf.py from minhtudragon/headroom_3: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/spaces/minhtudragon/headroom_3/resolve/823b8dc3bb2c57bc3f7b6cabcbacaa82ef77d077/headroom/cli/perf.py
- Command line
-
hf download hf://spaces/minhtudragon/headroom_3@823b8dc3bb2c57bc3f7b6cabcbacaa82ef77d077/headroom/cli/perf.py
-
curl -L -o perf.py https://huggingface.co/spaces/minhtudragon/headroom_3/resolve/823b8dc3bb2c57bc3f7b6cabcbacaa82ef77d077/headroom/cli/perf.py
1.58 kB
| """Performance analysis CLI command.""" | |
| import click | |
| from .main import main | |
| def perf(hours: float, raw: bool) -> None: | |
| """Analyze proxy performance from logs. | |
| \b | |
| Reads logs from ~/.headroom/logs/proxy.log and shows: | |
| - Token savings and compression effectiveness | |
| - Cache hit rates and prefix stability | |
| - Transform and routing breakdown | |
| - TOIN learning status | |
| - Actionable recommendations | |
| \b | |
| Examples: | |
| headroom perf Analyze last 7 days | |
| headroom perf --hours 24 Analyze last 24 hours | |
| headroom perf --raw Show raw parsed records | |
| """ | |
| from headroom.perf.analyzer import format_report, parse_log_files | |
| report = parse_log_files(last_n_hours=hours) | |
| if raw: | |
| for r in report.perf_records: | |
| click.echo( | |
| f"{r.timestamp} {r.request_id} model={r.model} msgs={r.num_messages} " | |
| f"before={r.tokens_before} after={r.tokens_after} saved={r.tokens_saved} " | |
| f"cache_read={r.cache_read} cache_write={r.cache_write} " | |
| f"cache_hit={r.cache_hit_pct}% opt={r.optimization_ms:.0f}ms" | |
| ) | |
| if not report.perf_records: | |
| click.echo("No PERF records found. Run the proxy first: headroom proxy") | |
| else: | |
| click.echo(format_report(report)) | |