Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

perftok-0.1.1.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

perftok-0.1.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file perftok-0.1.1.tar.gz.

File metadata

  • Download URL: perftok-0.1.1.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for perftok-0.1.1.tar.gz
Algorithm Hash digest
SHA256 18df444f05b3356cf7ac49488e34abcfc379f047162b9d8b3a761dc51989289b
MD5 14a383026bd0b094ee2e3b6762a5339c
BLAKE2b-256 ca5739a1d2eb153935c5cc40d6f2e39244f2d02db9e5f4e50f832fb1c5c58a17

See more details on using hashes here.

File details

Details for the file perftok-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: perftok-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for perftok-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 01f24b244b0b7fed06adf39540bda8b6009c14461cbf13f2d7249eac78d5b25d
MD5 4899ecff119741a777154df6226f9d96
BLAKE2b-256 6ff6cbce47371a7c8b13a8fd9a42355a87838cd2d4e289cf899f097da264649d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page