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- 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.
- 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.
- 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.