The library

How a program runs

Measure where a program's time goes and believe the result, well enough to know which kind of profiler answers your question, to recognise the four ways a profile lies, and to prove a change helped rather than assuming it

Reading a Profile Honestly

A profile is evidence, and most people read it wrong. This course covers how the measurements are taken, what each method distorts, why the top of the list is often not the problem, and how to show a change was real.

8 lessons, written and corrected before you arrived. Reading them here needs no account. The first reads the whole way through; the others open and then stop, because a page nobody owns cannot tell who is reading it. Starting the course gives you your own copy, where every idea has problems standing under it and you can ask about any sentence.

Start reading

  1. 01It Is Slow Is Not a Measurement, and Profiling Before You Have One Wastes the WeekFour different complaints all arrive as the word slow, and each one needs a different measurement. Turning the complaint into a statement with a number in it is the first and largest step.
  2. 02One Profiler Interrupts a Thousand Times a Second and Guesses, the Other Watches Every Call and Changes the Answeropening onlyThe two ways of measuring a program are a statistical sample and a complete count. They have different costs, different resolutions and different distortions, and the question decides which.
  3. 03The Function at Number Seven Received Nine Samples, Which Means You Know Almost Nothing About Itopening onlyEvery share in a sampling profile is an estimate with an uncertainty, and the uncertainty depends on how many samples that line received. One square root tells you which lines to believe.
  4. 04The Function Holding Ninety Per Cent of the Time Does Nothing, and the One Doing the Work Holds Four Per Centopening onlyA profile has two time columns and they answer different questions. Reading the wrong one sends you to a function that is innocent or to one that cannot be fixed.
  5. 05The Same Function Is Cheap in Two Places and Ruinous in the Third, and the Flat List Shows One Numberopening onlyA profile is a tree flattened into a list, and flattening discards which path the time came from. Reading the tree finds the caller to fix instead of the function to blame.
  6. 06Three and a Half of the Four Seconds Are Invisible, Because the Profiler Only Looks When the Program Is Runningopening onlyA processor profile samples a thread while it executes. A thread that is waiting executes nothing, so the wait leaves no trace and the profile reports a program with no problem.
  7. 07The Sample Landed Three Instructions After the One That Was Slow, and the Function It Blames Does Not Exist Any Moreopening onlyEven a correctly taken profile of the right thing puts time on the wrong line in four specific ways. All four are recognisable, and knowing them changes what you trust.
  8. 08The New Version Is Eight Per Cent Faster, and So Is the Old One If You Run It Enough Timesopening onlyA single before and after pair proves nothing, because the same program run twice differs by more than most improvements. Here is the comparison that survives that, and how to report it.