New: Try Voli The Bear, Fast package manager (and not only) for Windows
All topics / Finding the Slow Thing (Profiling 101)

Finding the Slow Thing (Profiling 101)

A profiler watches your program run and tells you where the time actually goes, so you fix the real bottleneck instead of guessing. Learn to read a profile and a flame graph, then run the measure-change-remeasure loop.

Download EPUB
  1. Measure, Don't Guess A profiler watches your program run and reports where the time actually goes. Your intuition about the slow part is usually wrong, and most of the time hides in a small spot - so measure first.
  2. Reading a Profile A profile ranks functions by time. The key distinction is self time (spent in the function itself) vs. cumulative time (it plus everything it called). A flame graph draws this as boxes where width = total time - the wide bar is your target.
  3. From Profile to Fix The loop: confirm the hypothesis, change exactly one thing, re-measure. The common wins are an accidental O(n²), an N+1 query, and repeated work you can cache. Profile a realistic workload, and don't optimize cold paths.