Skip to content
aiqbenchAI & Quantum Intelligence
NewsInsightsBenchmarksSkillsAsk AILearnAbout
...Loading your session
NewsInsightsBenchmarksSkillsAsk AILearnAbout
  1. Future Jobs
  2. ›
  3. AI Inference & Efficiency Engineer
  4. ›
  5. Lesson 6 of 8

Measuring Latency and Cost Honestly

Advanced¶ Read · 4 min⚑ Mission · 35 min◆ Test · 5 questions✓ Checked Nov 23, 2026

You'll be able to:

You can define time-to-first-token, inter-token latency, tokens per second and goodput, explain why averages and single-request benchmarks mislead, compute cost per million tokens from an hourly machine price and a measured throughput, and list the ways a vendor benchmark can be technically true and still irrelevant to your production load.

Define the metric before you run the benchmark

Inference benchmarks are easy to make look good and hard to make honest. The reason is that "fast" hides four different quantities, and a system can be excellent at one while being unusable on another. Before any run, write down which of these you are reporting:

  • Time to first token (TTFT) — from request arrival to the first streamed token. Dominated by queueing and prefill; it is what a user experiences as "is it thinking?".
  • Inter-token latency (ITL), or its inverse, per-user tokens per second — how fast the answer streams once started. Dominated by the decode step time at the current batch size.
  • End-to-end latency — TTFT plus ITL × output length. The only thing that matters for non-streaming API calls.
  • Throughput — total tokens per second across all users, which is what sets cost. Report input and output tokens separately; they cost different amounts of work.

A fifth, goodput, is throughput counted only for requests that met a latency target. It is the honest number for capacity planning, because a server that produces 10,000 tokens/s while every user waits 20 seconds for the first one is not serving anyone.

Why averages lie

Gil Tene's talk "How NOT to Measure Latency" is required viewing. Three of his points matter most here. First, the mean of a latency distribution describes nobody; users experience the tail, and a session of twenty requests sees at least one response at or beyond the p95 about two times in three (1 − 0.95²⁰ ≈ 64%). Second, coordinated omission: if your load generator waits for each response before sending the next request, a slow period causes it to send fewer requests, and the slow period is under-sampled in your data. The fix is an open-loop generator that fires requests on a schedule regardless of responses (a Poisson arrival process at a chosen rate), and a closed-loop generator only when your real clients genuinely behave that way. Third, percentiles must come from the full set of recorded samples, not from averaging percentiles across intervals, which is meaningless.

For LLM serving, add a fourth: the distribution of prompt and output lengths shapes everything. A benchmark with 128-token prompts and 128-token outputs says nothing about your 3,000-token RAG prompts and 50-token answers. Databricks' "LLM Inference Performance Engineering: Best Practices" shows the same hardware producing very different numbers as input/output shapes and concurrency change, and gives the practitioner's checklist for stating them.

Turning tokens per second into money

Cost per token is a derived number and the derivation should be shown. A numbered procedure:

  1. Measure sustained aggregate throughput at the concurrency and latency target you actually accept — say 2,400 output tokens/s at 32 concurrent users with p99 TTFT under 1.5 s.
  2. Convert to tokens per hour: 2,400 × 3,600 = 8.64 million output tokens per hour.
  3. Divide the machine's hourly price by that. If the machine costs 4.00 per hour in your currency, the cost is 4.00 ÷ 8.64 ≈ 0.46 per million output tokens at full utilisation.
  4. Correct for real utilisation. Traffic has peaks and valleys; if the server averages 40% of peak over a day, the effective cost is 0.46 ÷ 0.4 ≈ 1.16 per million. Autoscaling narrows the gap but adds cold-start latency.
  5. Add input tokens with their own throughput measurement, and overheads: idle replicas for failover, the engineer-hours of running it, and egress.

Compare that number to an API price only after step 4. Most "self-hosting is 10× cheaper" claims stop at step 3.

Vendor benchmarks: true but irrelevant

MLPerf Inference, run by MLCommons, is the most rigorous public benchmark: fixed models, fixed datasets, accuracy constraints, audited submissions, and separate "server" (latency-constrained) and "offline" (max throughput) scenarios. Read the rules before the results and you learn what a careful benchmark must specify. Even so, its numbers come from vendors' best-tuned configurations on the benchmark's shapes. Ways a published figure can be accurate and still useless to you:

  • Measured at a batch size or sequence shape you will never see.
  • Offline scenario quoted as if it were a latency-bound one.
  • Different precision (FP8) than you are willing to run.
  • Warm KV cache from repeated identical prompts (prefix caching inflates throughput enormously on synthetic loads).
  • Short runs that never hit thermal or memory-fragmentation steady state.

Your own benchmark should state model, precision, server version, hardware, prompt and output length distributions, concurrency, arrival process, warm-up, duration, and the percentiles reported — every time, in the results table.

What is still unsettled

Reasoning models that generate long hidden chains of thought make "output tokens" an ambiguous quantity for pricing, and goodput definitions for agentic, multi-call workloads are not standardised. Energy per token is the metric many organisations will soon be asked to report and few currently measure.

What to remember

  • Name the metric: TTFT, inter-token latency, end-to-end latency, throughput (input and output separately), goodput.
  • Report percentiles from full samples, use open-loop load to avoid coordinated omission, and match the workload's length distribution.
  • Cost per million tokens = hourly price ÷ (sustained tokens/s × 3,600), then divided by real utilisation; stopping before utilisation flatters self-hosting.
  • A vendor number is only comparable when model, precision, shapes, concurrency, scenario and caching state are the same as yours.

Curated Materials

1.7h

The deep work happens here — the lesson is your briefing.

  • How NOT to Measure Latency (Gil Tene, Strange Loop)Video· 45 min
  • LLM Inference Performance Engineering: Best Practices (Databricks)Tutorial· 30 min
  • MLPerf Inference: Datacenter benchmark suite (MLCommons)Docs· 25 min

Live on aiqbench

This lesson's subject on the rest of the site, today.

In the news, last 30 days

  • GPU decoder keeps pace with a superconducting qubit clock on a continuous stream, with NVIDIA NVQLink interconnectAlice & Bob · Dec 1
  • DeepSeek Opens Source Production-Level Ascend Inference Code36Kr · Dec 1
  • NVIDIA and Cerebras Partner to Accelerate AI Agent Inference with Two-Stage Compute Architecture36Kr · Dec 1
More news on this subject →

Go further

  • Which model is worth it?Price, speed and hardware next to capability.
  • Ask AI about this lessonOpens Ask AI with a question about this lesson, answered from the news archive with sources.
  • Agent skills for this workReady-made skills for AI coding agents, checked and rated.

Test your knowledge

5 questions in 100 seconds, on a page of its own. Read everything above first.

Test your knowledge →

Module Mission

30–40 min

Design a benchmark plan for a hypothetical customer-support assistant: 600-token prompts, 150-token answers, 20 concurrent users at peak. Write it as a one-page document covering the exact metrics you will report (with definitions), the load pattern (open-loop versus closed-loop, and why), the warm-up and run duration, what percentiles you will quote and why p99 rather than mean, how you will turn tokens/s into cost per million tokens, and the three mistakes from Gil Tene's talk you are explicitly guarding against.

Loading your work…

← Previous lesson5. Accelerators: GPU, TPU, CPU and Edge — What the Memory Hierarchy DecidesNext lesson →7. Caching, Routing and the Small-vs-Large Model Decision
aiqbench
AI & Quantum Intelligence© aiqbench. All rights reserved.

Feeds:RSS·JSON Feed

LanguageEnglish·Românăbeta
NewsAI & TechQuantumInsights
ExploreBenchmarksLearn
CompanyAboutTrustLegal noticeTerms of ServicePrivacy PolicyCopyright noticesData erasureReport content

The aiqbench take, the insights, the daily digest and Ask answers are written by AI models from the sources shown, without editorial review before publication. They may contain errors — check the source. How the model is used →

  • News
  • Insights
  • Ask AI
  • Benchmarks
  • Account