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 run \
  --url http://localhost:8000 \
  --num-requests 100 \
  --concurrency 10

# Specify model explicitly
perftok run \
  --model meta-llama/Meta-Llama-3-8B-Instruct \
  --url http://localhost:8000 \
  --num-requests 100 \
  --concurrency 10

# Hosted endpoint with API key
perftok run \
  --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 run [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 with a run subcommand
  • Output: Rich tables, JSON, CSV

Development

pip install -e ".[dev]"
pytest -v              # 76 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.0.tar.gz (20.8 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.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: perftok-0.1.0.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for perftok-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c0cb76c19cacc75aef6ae61ae28318f6ffdc84a12913cfa05d6eaa662ee2b342
MD5 f77ec7fa01a59c8fdc98fc92ca8d25a6
BLAKE2b-256 ab6d55d7c34723d9415a78b62e4d0050f0d202b1cadbba95584b1cc24652f7d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: perftok-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for perftok-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 724b7d24d4138511a9c97e1f241fed8fe81878a94e64ca76c321b627525beac5
MD5 5af2380a2947f0c2ac4a8e463c11a508
BLAKE2b-256 aceaa613898e79b0320ee5be69bf205c4e30377e5df9dab75df754207550d560

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