gprof2dot is a Python script that converts the output from various profilers (e.g., cProfile, gprof, Valgrind callgrind, Linux perf, Java HPROF) into a Graphviz dot graph. This allows for visual analysis of performance bottlenecks and call flows within an application. The library is actively maintained with a current version of 2025.4.14, typically releasing updates on a yearly or bi-yearly basis.
pip install gprof2dotVerified import paths — ran on the pinned version, not inferred.
To use gprof2dot, first profile your application using a compatible profiler (e.g., Python's `cProfile`). Save the profiling output to a file. Then, use the `gprof2dot` command-line tool to convert this profiling data into the Graphviz DOT language, piping the output to the `dot` command (from Graphviz) to generate a visual graph image (e.g., PNG or SVG).
Install Graphviz separately and ensure its `dot` executable is in your system's PATH.
Ensure you are running gprof2dot with Python 3.8 or a later version.
Be aware of `gprof`'s limitations. For C/C++ profiling, consider alternative profilers like Valgrind's Callgrind or Linux `perf` for more accurate call graph information. Always compile with the `-pg` flag for `gprof` to work.
Use the `-s` / `--strip` option to remove function parameters, template parameters, and const modifiers, or the `-w` / `--wrap` option to wrap long labels for better readability.
Users should be aware of the project's maintenance status and manage expectations for new features or rapid bug fixes.
Run the script using `python -m gprof2dot` if installed via pip, or ensure the directory containing `gprof2dot` is added to your system's PATH, or execute it directly with `python gprof2dot.py` if downloaded.
Install Graphviz on your system (e.g., `sudo apt-get install graphviz` on Debian/Ubuntu, `brew install graphviz` on macOS) and ensure its executable is in your system's PATH.
Verify that the input file is valid, correctly generated by the profiler, and that the correct format is specified using the `-f` flag (e.g., `-f python` for `cProfile` outputs, `-f callgrind` for Valgrind outputs).
Use one of the valid format choices listed in the error message, such as `python` for `cProfile` outputs, `callgrind` for Valgrind outputs, or `perf` for Linux `perf` data.