TRT
Sign in

Expert · Module 13 · Lesson 4 of 6

Benchmarking: Clocks, Warmup and Honest Numbers

Time C++ code with high-resolution clocks, defeat optimizer tricks, warm up caches, and report numbers that survive a rerun.

Pro — members onlyAbout 10 minutes

By the end you can

  • Time a loop with chrono without measuring setup by accident
  • Keep the optimizer from deleting the work being measured
  • Explain warmup, repetition and why one run never counts

Builds on Lock-Free Queues: Compare-Exchange and Reclamation.

01 · A question first

You optimize the allocator and the benchmark says 40 percent faster. You run it again and it says 10 percent slower. Nothing changed except the machine's mood. What was the first number actually measuring, and how do you get one that repeats?

Make a guess before you read on.

02 · The idea

Members only

Unlock the full lesson

This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.

What's inside

  • Start with the problem
  • How the idea works
  • A stopwatch for runners
  • Why it is correct
  • What it costs
  • Pitfalls and variations
  • Where it is used

03 · Practice

Something wrong with this lesson? Report a problem