RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /How-to
  5. /How to benchmark model response time using the Ollama API
HOW-TO · INF

How to benchmark model response time using the Ollama API

intermediate·15 min·By Fredoline Eruo
Target environment
Ubuntu 24.04 · Ollama 0.4.x
PREREQUISITES

Ollama running on localhost or a reachable host, curl or Python installed

What this does

Measures end-to-end latency from HTTP request dispatch to complete response receipt using command-line timing tools and API metadata. After this guide a reproducible wall-clock benchmark and tokens-per-second metric will be available for any model on the current hardware.

Steps

  1. Send a request and measure total wall-clock time. Captures end-to-end request duration using the time command.

    time curl -s http://localhost:11434/api/generate -d '{
      "model": "llama3:q4_K_M",
      "prompt": "Explain quantum entanglement in one sentence.",
      "stream": false
    }' | jq .
    

    Expected output: JSON response body followed by real time showing total elapsed seconds.

  2. Parse timing fields from the API response. The Ollama API returns eval_count (tokens generated) and eval_duration (nanoseconds spent generating).

    curl -s http://localhost:11434/api/generate -d '{
      "model": "llama3:q4_K_M",
      "prompt": "Explain quantum entanglement in one sentence.",
      "stream": false
    }' | jq '{eval_count, eval_duration}'
    

    Expected output: JSON object with numeric values for tokens and duration.

  3. Calculate tokens per second from these fields. Divides eval_count by eval_duration after converting nanoseconds to seconds.

    curl -s http://localhost:11434/api/generate -d '{"model":"llama3:q4_K_M","prompt":"Count from one to ten.","stream":false}' | jq '.eval_count / (.eval_duration / 1e9)'
    

    Expected output: A floating-point number representing tokens per second.

  • Record the local run evidence. Save the exact command, runtime or package version, model name if applicable, and observed output so the result can be reproduced later.

Verification

time curl -s http://localhost:11434/api/generate -d '{"model":"llama3:q4_K_M","prompt":"Count from one to five.","stream":false}' | jq .
# Expected: JSON response with "response" field and wall-clock time displayed

Common failures

  • connection refused - Ollama service is not running or URL is wrong; start with ollama serve.
  • empty response body - Model name is incorrect or request format is invalid; check JSON payload keys.
  • jq command not found - Install jq via package manager or parse JSON with Python instead.
  • stream mode missing timing fields - Set "stream": false for benchmark runs to get eval_count and eval_duration.
  • high variance across runs - Cold-start effects and system load contribute to outliers; run three iterations and discard the first.

Related guides

  • How to benchmark token generation speed in tokens per second
  • How to measure memory usage during model inference
RELATED GUIDES
INF
How to benchmark token generation speed in tokens per second
INF
How to measure memory usage during model inference
← All how-to guidesCourses →