To measure a local model’s real performance, track three numbers separately: how fast it processes the prompt, how fast it generates new tokens, and how much memory it peaks at. A single “tokens per second” figure collapses these into one value and hides the latency users actually notice — a model can generate at a comfortable rate and still make people wait several seconds before the first word appears.
This guide is for anyone running models through llama.cpp or Ollama who wants numbers they can trust and compare. It covers the metrics that matter, the commands that produce them, how to account for VRAM beyond the model file, and how to make repeated runs comparable.
Prompt processing and generation are two different speeds
The first thing to separate is prompt processing from text generation. Prompt processing (abbreviated pp) is the rate at which the model ingests input tokens; text generation (tg) is the rate at which it produces output tokens. Both are measured in tokens per second, but they describe different phases of a request and they scale differently with hardware, batch size, and context length.
A related metric is time-to-first-token (TTFT): the wall-clock delay before any output appears. TTFT is dominated by prompt processing, so a long document can produce a slow first response even when generation is fast. EngineersOfAI describes a deployment where a Q4_K_M Llama-3-8B generated at 42 tokens/second but took 3.8 seconds to reach the first token on long documents, and the team had assumed the latency complaints were a UI problem [2]. That scenario is illustrative rather than a measured result you should expect, but the failure mode is common: measuring only generation speed hides the delay users feel most.
| Metric | What it measures | Where it comes from |
|---|---|---|
| Prompt processing (pp) | Input tokens per second | llama-bench -p; Ollama prompt eval |
| Text generation (tg) | Output tokens per second | llama-bench -n; Ollama eval |
| Time-to-first-token | Delay before first output | Derived from prompt eval duration |
| Peak memory | Highest VRAM or RAM used | llama-bench VRAM column; system monitor |
Prerequisites and a baseline stack
The examples below assume a working local inference setup. The how2.sh benchmarking guide lists the minimum stack as llama.cpp built from source or Ollama 0.3+, a GPU with CUDA 12+ or Apple Silicon for accelerated inference, and Python 3.10+ if you want a scripted harness [1]. You can run the commands without Python; the language only matters once you move to automated comparisons.
Before measuring, confirm the model loads and answers a prompt at all. Benchmarking a configuration that fails under load wastes time and produces noise.
Benchmark raw speed with llama-bench
llama.cpp ships a dedicated benchmark binary that isolates the two speeds without a chat template or sampling in the way. A typical invocation sets the prompt size, the generation size, how many layers to offload, and the thread count:
./llama-bench -m models/llama-3.1-8b-q4_k_m.gguf -p 512 -n 128 -ngl 99 -t 8Here -p 512 requests a 512-token prompt, -n 128 requests 128 generated tokens, -ngl 99 offloads layers to the GPU, and -t 8 sets CPU threads. The output is a compact table:
model | pp 512 | tg 128 | VRAM
llama-3.1-8b-q4_k_m | 1847.21 | 98.42 | 5.2 GBIn that layout, pp is prompt processing in tokens per second, tg is text generation in tokens per second, and the VRAM column is the memory the run reported [1]. The specific figures above are the example published by how2.sh, not a universal baseline — your numbers will depend on your GPU, driver, quantization, and context settings.
Because -p and -n are explicit, llama-bench is the right tool when you want to compare hardware or quantization levels under a fixed workload. It is not a substitute for measuring a real request, which includes template overhead and variable prompt lengths.
Measure a real request with Ollama
Ollama reports per-request statistics when you pass --verbose. Pull a quantized model and time a single inference:
ollama pull llama3.1:8b-instruct-q4_K_M
time ollama run llama3.1:8b-instruct-q4_K_M "Write a Python function to merge two sorted lists" --verboseThe trailing lines of the verbose output break the request into phases: total duration, load duration, prompt eval count, prompt eval duration, eval count, and eval duration [1]. A published example shows 18 prompt tokens evaluated in 12 ms (about 1500 tok/s) and 156 tokens generated in 2.601 s (about 59.97 tok/s) [1].
Two cautions when reading these numbers. First, the prompt here is tiny compared with llama-bench’s 512 tokens, and prompt processing rate changes with prompt size, so do not compare the two directly. Second, load duration reflects model loading and is not part of steady-state inference; keep it separate when you report latency.
Measure VRAM, not just the model file
The size of the .gguf file is not the memory the model uses while running. Three components add up:
- Weights. The quantized file size is a reasonable starting estimate, but it is not the whole picture.
- KV cache. This grows with context length and batch size. Doubling the context can meaningfully raise memory use, which is why benchmarks that fix context length are easier to compare.
- Runtime overhead. CUDA context, compute buffers, and framework allocations consume memory outside the weights.
llama-bench reports a VRAM column, which is convenient for a single run. For a long-lived server, watch memory at the system level instead. On NVIDIA hardware, nvidia-smi shows per-process GPU memory; on Apple Silicon, Activity Monitor or a GPU-aware tool exposes unified memory use. Because context length drives the KV cache, always note the context window you configured alongside any memory figure. Presenting weight size as total memory use is one of the most common reporting errors in local-model benchmarks.
Make repeated runs comparable
A single run tells you very little, because the first inference after loading is slower and thermal throttling can change later ones. The benchmarking guide from EngineersOfAI emphasizes warm-up runs, statistical methods, and thermal controls for exactly this reason [2]. A workable protocol:
- Run at least one warm-up pass and discard it.
- Use a fixed prompt set so every configuration sees identical input.
- Repeat each measurement several times and report a range or median rather than one number.
- Hold context length, quantization, and sampling settings constant while comparing.
- Record the environment: OS, driver, runtime version, model name, quantization, GPU, and memory.
For structured comparisons across models or quantization levels, how2.sh describes a Python harness that runs the same prompt set against each configuration and collects the results into a table [1]. That is the point at which scripting pays off — manual runs are fine for a one-off check, but they are hard to keep consistent.
Interpreting the results honestly
Tokens per second is a workload-specific measurement, not a property of a model. The same weights can produce very different figures under a different quantization, context length, batch size, or offload configuration. Two consequences follow.
First, do not compare numbers collected under different settings as if they were like-for-like. A generation rate measured with a 4-bit quantization and a short context is not evidence about the same model at 8-bit with a long context. Second, treat published figures — including the examples cited here — as illustrations of format and method, not as targets. If your numbers are lower, the useful next step is to check context length, offload settings, and thermal state before assuming something is wrong.
If you need a single headline number for a decision, pick the metric that matches the workload: generation speed for long outputs, prompt processing and TTFT for long inputs, and peak memory for capacity planning. Reporting all three, with the configuration attached, is what makes a benchmark reproducible by someone else.
Where to go next
Start with one workload you actually care about, run it three to five times with a fixed prompt, and record the configuration alongside the results. Then change exactly one variable — quantization, context length, or offload setting — and measure again. That single-variable habit produces more useful information than any one-off score. Readers are welcome to share their goal, hardware, and measured results in the community so others can compare setups.
FAQ
Why is my tokens-per-second figure lower than a benchmark I saw online?
Tokens per second depends on the specific configuration: GPU, driver, quantization, context length, batch size, and offload settings. Published figures are usually collected under different settings, so they are not directly comparable. Check your context length and offload configuration first, and confirm the GPU is not thermally throttling.
Does quantization change VRAM usage?
Yes. Lower-precision weights reduce the memory needed for the model file, which is one reason quantized models are popular locally. However, the total memory in use also includes the KV cache and runtime overhead, so weight size alone does not determine peak VRAM.
Should I report one tokens-per-second number or several?
Report them separately. Prompt processing and generation scale differently, and time-to-first-token is often the metric users actually feel. For capacity planning, peak memory matters as much as speed.