How to measure Ollama tokens per second without mixing timings
Divide eval_count by eval_duration in seconds for generation tokens per second. Divide prompt_eval_count by prompt_eval_duration in seconds for prompt processing throughput. The Ollama API reports durations in nanoseconds, so divide duration values by 1,000,000,000 before computing either rate. Time to first visible text requires its own client-side observation. [1]
- LoadBring weights into memoryload_duration
- Process promptPrepare the input contextprompt_eval_count and duration
- GenerateProduce output tokenseval_count and duration
| Stage | API counts and duration | Calculated result |
|---|---|---|
| Prompt | 1,200 tokens in 3,000,000,000 ns | 400 tokens/s |
| Generation | 160 tokens in 4,000,000,000 ns | 40 tokens/s |
| Cold load | 2,000,000,000 ns | 2 seconds of load time |
Record cold and warm cases separately
For a cold case, check that the model is not resident with ollama ps before starting and record the first request. For a warm case, repeat while the model stays loaded. Preserve the model tag, quantization, context, API options, runtime version, prompt input and device placement. Repeated prompts can use cached work. Report the actual prompt count recorded by the API for each test when comparing prompt throughput. [1] [2]
Measure the user-visible delay independently
Use a streaming request for a separately timed run. Record elapsed wall-clock time from sending the request to receiving the first chunk containing visible response text. State whether you count reasoning text, and keep that rule the same. Capture the final response timing fields as well. Network and application overhead can show up on the client clock even when model generation is unchanged. If a timing denominator is zero or absent, leave that rate blank. [1]
Compare only the differences you meant to change
Alternate multiple runs across configurations. Record a median and range with the sample count. Keep model, prompt, context, output cap and placement policy constant to test a hardware change. Use long prompts and short prompts as separate workloads. A llama.cpp benchmark can isolate prompt or generation test modes, while your actual application includes layers such as conversation history and networking. Pick the test that matches the decision you need to make. [3]
Put it into practice
Related guides
Sources
Source review . Research and writing prepared with AI assistance.