A Rust tool for converting Google gperftools CPU profiler output to FlameGraph visualization format.
- 📊 Parse binary output from gperftools CPU profiler
- 🔍 Resolve symbols with demangling support
- 🧰 Customizable output options for visualization
- 📝 Generate text format for debugging or further processing
- 🚀 Performance optimized with Rust
build from source:
cargo build --release
Basic syntax:
g2f <EXECUTABLE> <PROFILE_FILE> [OPTIONS]
Parameters
<EXECUTABLE>
: Path to the executable binary that was profiled<PROFILE_FILE>
: Path to gperftools CPU profiler result file
Options
Option | Description |
---|---|
--help |
Show help message |
--svg-output <PATH> |
Path for SVG flamegraph output |
--text-output <PATH> |
Path for text format output |
--simplify-symbol |
Simplify symbol names (remove template/function args) |
--executable-only |
Only resolve symbols from the executable (ignore libraries) |
--annotate-libname |
Add library name annotations like [libname.so] |
--to-microsecond |
Use microseconds as time unit (default is sample count) |
--flamegraph-path <PATH> |
Path to flamegraph.pl script (default: "flamegraph.pl") |
g2f <gprof_output_file> <output_file>
g2f <EXECUTABLE> gprof.prof --svg-output gprof.svg --text-output gprof.txt
Note: The generated SVG files are best viewed in a modern browser. For large profiles, consider using the --simplify-symbol
option to improve readability.
If you encounter "Failed to start flamegraph.pl" error:
# Option 1: Install FlameGraph and specify path
git clone https://github.com/brendangregg/FlameGraph.git
./g2f myapp cpu.prof --svg-output out.svg --flamegraph-path ./FlameGraph/flamegraph.pl
# Option 2: Add FlameGraph to your PATH
export PATH=$PATH:$(pwd)/FlameGraph
If you see too many "???" unknown symbols:
- Ensure your binary was compiled with debug information (-g flag)
- Check that you're providing the correct executable path
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Mulan PSL v2 License - see the LICENSE file for details.
This project is inspired by gperftools_flamegraph_profiler.