@@ -1003,6 +1003,47 @@ at the top indicate functions that consume significant time either directly
10031003or through their callees.
10041004
10051005
1006+ Differential flame graphs
1007+ ~~~~~~~~~~~~~~~~~~~~~~~~~
1008+
1009+ Differential flame graphs compare two profiling runs to highlight where
1010+ performance changed. This helps identify regressions introduced by code changes
1011+ and validate that optimizations achieved their intended effect::
1012+
1013+ # Capture baseline profile
1014+ python -m profiling.sampling run --binary -o baseline.bin script.py
1015+
1016+ # After modifying code, generate differential flamegraph
1017+ python -m profiling.sampling run --diff-flamegraph baseline.bin -o diff.html script.py
1018+
1019+ The visualization draws the current profile with frame widths showing current
1020+ time consumption, then applies color to indicate how each function changed
1021+ relative to the baseline.
1022+
1023+ **Color coding **:
1024+
1025+ - **Red **: Functions consuming more time (regressions). Lighter shades indicate
1026+ modest increases, while darker shades show severe regressions.
1027+
1028+ - **Blue **: Functions consuming less time (improvements). Lighter shades for
1029+ modest reductions, darker shades for significant speedups.
1030+
1031+ - **Gray **: Minimal or no change.
1032+
1033+ - **Purple **: New functions not present in the baseline.
1034+
1035+ Frame colors indicate changes in **direct time ** (time when the function was at
1036+ the top of the stack, actively executing), not cumulative time including callees.
1037+ Hovering over a frame shows comparison details including baseline time, current
1038+ time, and the percentage change.
1039+
1040+ Some call paths may disappear entirely between profiles. These are called
1041+ **elided stacks ** and occur when optimizations eliminate code paths or certain
1042+ branches stop executing. If elided stacks are present, an elided toggle appears
1043+ allowing you to switch between the main differential view and an elided-only
1044+ view that shows just the removed paths (colored purple).
1045+
1046+
10061047Gecko format
10071048------------
10081049
@@ -1488,6 +1529,10 @@ Output options
14881529
14891530 Generate self-contained HTML flame graph.
14901531
1532+ .. option :: --diff-flamegraph <baseline.bin >
1533+
1534+ Generate differential flamegraph comparing to a baseline binary profile.
1535+
14911536.. option :: --gecko
14921537
14931538 Generate Gecko JSON format for Firefox Profiler.
0 commit comments