https://github.com/emin017/gperf2flamegraph
A tool for converting Google gperftools profiler output to FlameGraph visualization format
https://github.com/emin017/gperf2flamegraph
flamegraph flamegraphs gperf gperftools rust rust-lang
Last synced: 10 months ago
JSON representation
A tool for converting Google gperftools profiler output to FlameGraph visualization format
- Host: GitHub
- URL: https://github.com/emin017/gperf2flamegraph
- Owner: Emin017
- License: mulanpsl-2.0
- Created: 2025-03-27T05:39:15.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-05-13T02:16:45.000Z (10 months ago)
- Last Synced: 2025-05-13T13:19:22.248Z (10 months ago)
- Topics: flamegraph, flamegraphs, gperf, gperftools, rust, rust-lang
- Language: Rust
- Homepage:
- Size: 78.1 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# โจ gperf2flamegraph (g2f) โจ







[](README.md)
A Rust tool for converting Google [gperftools](https://github.com/gperftools/gperftools) CPU profiler output to [FlameGraph](https://www.brendangregg.com/flamegraphs.html) visualization format.
## ๐ฅ Features
* ๐ 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
## ๐ ๏ธ Installation
build from source:
```shell
cargo build --release
```
## ๐ Usage
Basic syntax:
```shell
g2f [OPTIONS]
```
Parameters
* ``: Path to the executable binary that was profiled
* ``: Path to gperftools CPU profiler result file
Options
| Option | Description |
|--------|-------------|
| `--help` | Show help message |
| `--svg-output ` | Path for SVG flamegraph output |
| `--text-output ` | 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 to flamegraph.pl script (default: "flamegraph.pl") |
## ๐งช Example
### Basic Usage
```shell
g2f
```
### With Options
```shell
g2f 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.***
## ๐ง Troubleshooting
### Missing flamegraph.pl
If you encounter "Failed to start flamegraph.pl" error:
```shell
# 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
```
### Symbol Resolution Issues
If you see too many "???" unknown symbols:
1. Ensure your binary was compiled with debug information (-g flag)
2. Check that you're providing the correct executable path
## ๐ค Contributing
Contributions are welcome! Please feel free to submit a [Pull Request](https://github.com/Emin017/gperf2flamegraph/pulls).
## ๐ License
This project is licensed under the Mulan PSL v2 License - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgements
This project is inspired by [gperftools_flamegraph_profiler](https://github.com/dwangxxx/gperftools_flamegraph_profiler).