Chapter 15: Performance and cost

Flame graph

Also called Flame chart

A picture of a profile. Each bar is a function, sitting on top of the one that called it, and the wider the bar, the more time it took. You look for the wide bars at the top: they are doing the work themselves, with nothing above them to blame.

A flame graph lets you check an agent's story at a glance. If it says the slowness is in the formatter and the widest bar is somewhere else, you can see that for yourself without reading a line of code, and without taking its word for it.

Say it to your agent

“Run py-spy record -o profile.svg -- python report.py and tell me the three widest frames with nothing above them, with their percentages. Propose a change only for those, and rerun it afterwards to show that frame got narrower.”

The workshop

Name a word, or describe what you mean in everyday language.