Linux command
flamegraph 命令
网络
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Generate flame graph from perf data
perf script | stackcollapse-perf.pl | flamegraph.pl > [flame.svg]
From dtrace output
stackcollapse.pl [out.dtrace] | flamegraph.pl > [flame.svg]
Custom title
flamegraph.pl --title "[My App Profile]" [stacks.txt] > [flame.svg]
Inverted (icicle) graph
flamegraph.pl --inverted [stacks.txt] > [flame.svg]
Set width
flamegraph.pl --width [1200] [stacks.txt] > [flame.svg]
说明
FlameGraph is a visualization tool for profiled stack traces, created by Brendan Gregg. It generates interactive SVG graphs where the x-axis shows the stack population and the y-axis shows stack depth. Flame graphs quickly reveal which code paths consume the most resources. They work with any profiler output that can be converted to the collapsed stack format.
参数
- --title _text_
- Title for the graph.
- --subtitle _text_
- Second level title (optional).
- --width _pixels_
- SVG width (default 1200).
- --height _pixels_
- Frame height (default 16).
- --minwidth _pixels_
- Omit functions narrower than this (default 0.1 pixels).
- --fontsize _num_
- Font size (default 12).
- --fonttype _font_
- Font type (default "Verdana").
- --countname _text_
- Count type label (default "samples").
- --nametype _text_
- Name type label (default "Function:").
- --inverted
- Generate icicle graph (top-down).
- --reverse
- Reverse stack order.
- --colors _palette_
- Color palette: hot (default), mem, io, wakeup, chain, java, js, perl, red, green, blue, aqua, yellow, purple, orange.
- --bgcolors _color_
- Background gradient: yellow (default), blue, green, grey, or flat "#rrggbb".
- --hash
- Color by function name hash.
- --cp
- Use consistent palette (palette.map).
- --flamechart
- Time-ordered flame chart (sort by time, do not merge stacks).
- --negate
- Switch differential hues (blue/red).
FAQ
What is the flamegraph command used for?
FlameGraph is a visualization tool for profiled stack traces, created by Brendan Gregg. It generates interactive SVG graphs where the x-axis shows the stack population and the y-axis shows stack depth. Flame graphs quickly reveal which code paths consume the most resources. They work with any profiler output that can be converted to the collapsed stack format.
How do I run a basic flamegraph example?
Run `perf script | stackcollapse-perf.pl | flamegraph.pl > [flame.svg]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --title _text_ do in flamegraph?
Title for the graph.