Lightweight benchmarking tool for OpenAI-compatible LLM endpoints
Project description
perftok
Lightweight benchmarking tool for OpenAI-compatible LLM endpoints.
perftok gives you the same metrics as aiperf (TTFT, ITL, throughput, latency percentiles) with a simple pip-installable CLI — no ZMQ services, no Ray dependency, no special binaries.
Installation
pip install perftok
Or from source:
git clone https://github.com/timsleeper/perftok.git
cd perftok
pip install -e ".[dev]"
Requires Python 3.10+.
Quick Start
# Benchmark a local vLLM / TGI / Ollama endpoint
perftok \
--url http://localhost:8000 \
--num-requests 100 \
--concurrency 10
# Specify model explicitly
perftok \
--model meta-llama/Meta-Llama-3-8B-Instruct \
--url http://localhost:8000 \
--num-requests 100 \
--concurrency 10
# Hosted endpoint with API key
perftok \
--url https://api.example.com \
--api-key $API_KEY \
--num-requests 50 \
--concurrency 5 \
--output-format json \
--output-file results.json
If --model is omitted, perftok queries /v1/models and prompts you to confirm.
CLI Options
perftok [OPTIONS]
--model TEXT Model name (auto-discovered if omitted)
--url TEXT Base URL of the endpoint [required]
--api-key TEXT API key (or set API_KEY env var)
--concurrency INTEGER Max concurrent requests [default: 1]
--num-requests INTEGER Total number of requests [default: 1]
--mean-input-tokens INTEGER Mean input prompt tokens [default: 550]
--stddev-input-tokens INTEGER Stddev of input tokens [default: 150]
--mean-output-tokens INTEGER Mean output tokens [default: 150]
--stddev-output-tokens INTEGER Stddev of output tokens [default: 10]
--timeout INTEGER Request timeout in seconds [default: 300]
--streaming / --no-streaming Use streaming SSE responses [default: streaming]
--output-format [table|json|csv] Output format [default: table]
--output-file TEXT Write results to file
Metrics
| Metric | Unit | Aggregation |
|---|---|---|
| TTFT (Time to First Token) | ms | p50 / p75 / p90 / p95 / p99 / min / max / mean / stddev |
| ITL (Inter-Token Latency) | ms | same |
| E2E Request Latency | ms | same |
| Output Token Throughput | tokens/s | system-wide aggregate |
| Output Throughput Per Request | tokens/s | per-request with percentiles |
| Request Throughput | req/s | aggregate |
| Error Rate | % | aggregate |
Output Formats
Table (default) — Rich-formatted summary printed to the terminal.
JSON — Full report as structured JSON, suitable for programmatic consumption.
CSV — Flattened single-row CSV with all metrics, handy for appending to spreadsheets.
Use --output-file to write results to disk in any format.
TLS/SSL
If TLS certificate verification fails, perftok exits with a clear error message. Pass --insecure to bypass verification — common with local inference servers behind self-signed certs.
Architecture
- Concurrency:
asyncio+aiohttp+Semaphore— no threads, no Ray, no ZMQ - Token counting:
tiktoken(cl100k_base) for exact prompt-length targeting - Models: Pydantic v2 for config validation and report serialization
- CLI: Click single-command interface
- Output: Rich tables, JSON, CSV
Development
pip install -e ".[dev]"
pytest -v # 89 tests
ruff check src/ tests/ # lint
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file perftok-0.1.2.tar.gz.
File metadata
- Download URL: perftok-0.1.2.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3fb77fda2af93dc74261f2351b20adfb31a9155a83e99cb9d2fcda7fdac4c36
|
|
| MD5 |
39c96c261bd3c03c0c790a238df6fa3f
|
|
| BLAKE2b-256 |
b16a8c06952b61cae50d7ef60e4c5013a6f3e584e3031106c1bf646710feef55
|
File details
Details for the file perftok-0.1.2-py3-none-any.whl.
File metadata
- Download URL: perftok-0.1.2-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63080c4074fceeb72968347f5b5e90aeed12648d6aae4daaa755ee279c5bbf6b
|
|
| MD5 |
4b49c6a8650179df6e206cc3905c4ae0
|
|
| BLAKE2b-256 |
6396efd53e1df4108ffd927fdf021ac226953c43d1fb6ca17dcfa5fffba6b798
|