ollama-benchmark-cli is a Python terminal tool for benchmarking local Ollama models with a standard prompt set. It streams responses from Ollama, measures speed, and prints a color-coded Rich table.
- Run 10 built-in benchmark prompts across math reasoning, coding, summarization, creative writing, and factual recall
- Use
--modelto benchmark any installed Ollama model - Use
--promptsfor a custom.txt,.md,.json, or.jsonlprompt file - Measure tokens/second, time to first token, total response time, and CLI RAM usage
- Show a Rich progress bar while prompts run
- Export benchmark results to CSV with
--output - Loads local config from
.envwithpython-dotenv - Includes
.env.example,.gitignore, andSECURITY.md
- Python 3.10+
- Ollama installed and running locally
- At least one Ollama model pulled, for example:
ollama pull llama3.2:3bpython -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txtOn macOS or Linux, activate the environment with:
source .venv/bin/activateCopy the example environment file:
copy .env.example .envOn macOS or Linux:
cp .env.example .envDefault .env values:
OLLAMA_HOST=http://127.0.0.1:11434
OLLAMA_REQUEST_TIMEOUT=120
OLLAMA_API_KEY=YOUR_API_KEY_HEREOllama does not need an API key for normal local use. Leave OLLAMA_API_KEY as the placeholder unless you later put Ollama behind a protected proxy.
Run the built-in benchmark prompt set:
python main.py --model llama3.2:3bExport results to CSV:
python main.py --model llama3.2:3b --output benchmark-results.csvUse a custom prompt file:
python main.py --model llama3.2:3b --prompts prompts.txtText and Markdown prompt files can use one prompt per line, or separate multi-line prompts with a line containing at least three dashes:
Explain TCP/IP in simple terms.
---
Write a Python function that validates email addresses.
JSON prompt file format:
[
{
"category": "coding",
"prompt": "Write a Python function that checks whether a number is prime."
},
{
"category": "reasoning",
"prompt": "If a clinic sees 24 patients in 3 hours, what is the average per hour?"
}
]JSONL prompt file format:
{"category":"coding","prompt":"Write a Python function that reverses a string."}
{"category":"summary","prompt":"Summarize why local AI benchmarking matters."}Benchmarking llama3.2:3b at http://127.0.0.1:11434
Running 10 prompt(s).
⠋ Running benchmark prompts ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10/10 0:02:11
Ollama Benchmark Results: llama3.2:3b
┏━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━┳━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┓
┃ # ┃ Category ┃ Prompt ┃ Tok/s ┃ TTFT ┃ Total ┃ RAM Δ ┃ Tokens ┃
┣━━━━╋━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━╋━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━┫
┃ 1 ┃ math reasoning ┃ A train travels 180 km... ┃ 31.42 ┃ 0.42s ┃ 4.02s ┃ +1.2 MB ┃ 126 ┃
┃ 2 ┃ math reasoning ┃ Solve this step by step... ┃ 29.88 ┃ 0.39s ┃ 3.51s ┃ +0.4 MB ┃ 105 ┃
┃ 3 ┃ coding ┃ Write a Python function... ┃ 24.16 ┃ 0.55s ┃ 6.79s ┃ +0.8 MB ┃ 164 ┃
┃ .. ┃ ... ┃ ... ┃ ... ┃ ... ┃ ... ┃ ... ┃ ... ┃
┗━━━━┻━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━┻━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━┛
Averages 27.84 tok/s 0.48s TTFT 4.91s total
CSV written to: C:\path\to\benchmark-results.csv
- Never commit real
.envfiles or secrets. - This CLI does not expose API endpoints, run SQL, accept uploads, use
eval(), or perform web scraping. - Inputs are length-limited and validated before being sent to Ollama or written to CSV.
- Errors are handled without printing stack traces or internal Python tracebacks.
This repository is already on GitHub, so you just clone and install — no git init needed.
git clone https://github.com/harisawan-bit/ollama-benchmark-cli.git
cd ollama-benchmark-cli
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
ollama-benchmark --helpRun the smoke tests (they do not need a live Ollama server):
pip install pytest
pytest -q- Create a feature branch from
main:git checkout -b feat/your-change main
- Make your change and add tests where it makes sense.
- Run
pytest -qandollama-benchmark --helplocally so they pass. - Push the branch and open a pull request against
main.
CI runs a smoke test on Python 3.10, 3.11, and 3.12. A PR can only be merged when all checks are green. See CONTRIBUTING.md for full details.