An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# โœจ gperf2flamegraph (g2f) โœจ


GitHub
Rust
Flamegraph
Gprof

![GitHub](https://img.shields.io/github/license/Emin017/gperf2flamegraph)
![GitHub workflows](https://img.shields.io/github/actions/workflow/status/Emin017/gperf2flamegraph/build.yml)
![GitHub issues](https://img.shields.io/github/issues/Emin017/gperf2flamegraph)
![GitHub pull requests](https://img.shields.io/github/issues-pr/Emin017/gperf2flamegraph)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/Emin017/gperf2flamegraph)

![GitHub stars](https://img.shields.io/github/stars/Emin017/gperf2flamegraph?style=social)
![GitHub forks](https://img.shields.io/github/forks/Emin017/gperf2flamegraph?style=social)

[![English](https://img.shields.io/badge/English-README-2ea44f?style=for-the-badge)](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).