# gprof2dot

> Generate a dot graph from the output of several profilers.

- **URL**: https://www.freshcrate.ai/projects/gprof2dot
- **Author**: Jose Fonseca
- **Category**: Developer Tools
- **Latest version**: `2025.4.14` (2026-04-21)
- **License**: LGPL
- **Source**: https://github.com/jrfonseca/gprof2dot
- **Language**: Python
- **GitHub**: 3,439 stars, 392 forks
- **Registry**: pypi (`gprof2dot`)
- **Tags**: `pypi`

## Description

# About _gprof2dot_

This is a Python script to convert the output from many profilers into a [dot graph](https://www.graphviz.org/doc/info/lang.html).

It can:

  * read output from:
    * [Linux perf](https://perf.wiki.kernel.org/)
    * [Valgrind's callgrind tool](https://valgrind.org/docs/manual/cl-manual.html)
    * [OProfile](https://oprofile.sourceforge.net/)
    * [Sysprof](http://www.sysprof.com/)
    * [Xperf](https://learn.microsoft.com/en-us/windows-hardware/test/wpt/)
    * [VTune](https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler.html)
    * [Very Sleepy](https://www.codersnotes.com/sleepy/)
    * [Python profilers](https://docs.python.org/3/library/profile.html#profile-stats)
    * [Java's HPROF](https://docs.oracle.com/javase/7/docs/technotes/samples/hprof.html)
    * prof, [gprof](https://sourceware.org/binutils/docs/gprof/)
    * [DTrace](https://en.wikipedia.org/wiki/DTrace)
    * stackcollapse from [FlameGraph](https://github.com/brendangregg/FlameGraph)
  * prune nodes and edges below a certain threshold;
  * use an heuristic to propagate time inside mutually recursive functions;
  * use color efficiently to draw attention to hot-spots;
  * work on any platform where Python and Graphviz is available, i.e, virtually anywhere;
  * compare two graphs with almost identical structures for the analysis of performance metrics such as time or function calls.

**If you want an interactive viewer for the graphs generated by _gprof2dot_, check [xdot.py](https://github.com/jrfonseca/xdot.py).**


# Status

_gprof2dot_ currently fulfills my needs, and I have little or no time for its
maintenance.  So I'm afraid that any requested features are unlikely to be
implemented, and I might be slow processing issue reports or pull requests.

[![Build Status](https://github.com/jrfonseca/gprof2dot/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/jrfonseca/gprof2dot/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/jrfonseca/gprof2dot/branch/main/graph/badge.svg?token=pBvnAuazx0)](https://codecov.io/gh/jrfonseca/gprof2dot)


# Example

This is the result from the [example data](https://linuxgazette.net/100/misc/vinayak/overall-profile.txt) in the [Linux Gazette article](https://linuxgazette.net/100/vinayak.html) with the default settings:

![Sample](./sample.svg)

# Requirements

  * [Python](https://www.python.org/download/): known to work with version >=3.8; it will most likely _not_ work with earlier releases.
  * [Graphviz](https://www.graphviz.org/Download.php): tested with version 2.26.3, but should work fine with other versions.

## Windows users

  * Download and install [Python for Windows](https://www.python.org/download/)
  * Download and install [Graphviz for Windows](https://www.graphviz.org/Download_windows.php)

## Linux users

On Debian/Ubuntu run:

    apt-get install python3 graphviz

On RedHat/Fedora run

    yum install python3 graphviz


# Download

  * [PyPI](https://pypi.python.org/pypi/gprof2dot/)

        pip install gprof2dot

  * [Standalone script](https://raw.githubusercontent.com/jrfonseca/gprof2dot/main/gprof2dot.py)

  * [Git repository](https://github.com/jrfonseca/gprof2dot)


# Documentation

## Usage

```
Usage: 
	gprof2dot.py [options] [file] ...

Options:
  -h, --help            show this help message and exit
  -o FILE, --output=FILE
                        output filename [stdout]
  -n PERCENTAGE, --node-thres=PERCENTAGE
                        eliminate nodes below this threshold [default: 0.5]
  -e PERCENTAGE, --edge-thres=PERCENTAGE
                        eliminate edges below this threshold [default: 0.1]
  -f FORMAT, --format=FORMAT
                        profile format: axe, callgrind, collapse, dtrace,
                        hprof, json, oprofile, perf, prof, pstats, sleepy,
                        sysprof or xperf [default: prof]
  --total=TOTALMETHOD   preferred method of calculating total time: callratios
                        or callstacks (currently affects only perf format)
                        [default: callratios]
  -c THEME, --colormap=THEME
                        color map: bw, color, gray, pink or print [default:
                        color]
  -s, --strip           strip function parameters, template parameters, and
                        const modifiers from demangled C++ function names
  --color-nodes-by-selftime
                        color nodes by self time, rather than by total time
                        (sum of self and descendants)
  -w, --wrap            wrap function names
  --show-samples        show function samples
  --node-label=MEASURE  measurements to on show the node (can be specified
                        multiple times): self-time, self-time-percentage,
                        total-time or total-time-percentage [default: total-
                        time-percentage, self-time-percentage]
  --list-functions=LIST_FUNCTIONS
                        list fun

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `2025.4.14` | 2026-04-21 | Low | Imported from PyPI (2025.4.14) |
| `2025.04.14` | 2025-04-14 | Low | ## What's Changed * Remove "%3" tooltip in SVG output by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/101 * Add an option to specify time format by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/102  ## New Contributors * @eltoder made their first contribution in https://github.com/jrfonseca/gprof2dot/pull/101  **Full Changelog**: https://github.com/jrfonseca/gprof2dot/compare/2024.06.06...2025.04.14 |
| `2025.04.14` | 2025-04-14 | Low | ## What's Changed * Remove "%3" tooltip in SVG output by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/101 * Add an option to specify time format by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/102  ## New Contributors * @eltoder made their first contribution in https://github.com/jrfonseca/gprof2dot/pull/101  **Full Changelog**: https://github.com/jrfonseca/gprof2dot/compare/2024.06.06...2025.04.14 |
| `2025.04.14` | 2025-04-14 | Low | ## What's Changed * Remove "%3" tooltip in SVG output by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/101 * Add an option to specify time format by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/102  ## New Contributors * @eltoder made their first contribution in https://github.com/jrfonseca/gprof2dot/pull/101  **Full Changelog**: https://github.com/jrfonseca/gprof2dot/compare/2024.06.06...2025.04.14 |
| `2025.04.14` | 2025-04-14 | Low | ## What's Changed * Remove "%3" tooltip in SVG output by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/101 * Add an option to specify time format by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/102  ## New Contributors * @eltoder made their first contribution in https://github.com/jrfonseca/gprof2dot/pull/101  **Full Changelog**: https://github.com/jrfonseca/gprof2dot/compare/2024.06.06...2025.04.14 |
| `2025.04.14` | 2025-04-14 | Low | ## What's Changed * Remove "%3" tooltip in SVG output by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/101 * Add an option to specify time format by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/102  ## New Contributors * @eltoder made their first contribution in https://github.com/jrfonseca/gprof2dot/pull/101  **Full Changelog**: https://github.com/jrfonseca/gprof2dot/compare/2024.06.06...2025.04.14 |
| `2025.04.14` | 2025-04-14 | Low | ## What's Changed * Remove "%3" tooltip in SVG output by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/101 * Add an option to specify time format by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/102  ## New Contributors * @eltoder made their first contribution in https://github.com/jrfonseca/gprof2dot/pull/101  **Full Changelog**: https://github.com/jrfonseca/gprof2dot/compare/2024.06.06...2025.04.14 |
| `2025.04.14` | 2025-04-14 | Low | ## What's Changed * Remove "%3" tooltip in SVG output by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/101 * Add an option to specify time format by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/102  ## New Contributors * @eltoder made their first contribution in https://github.com/jrfonseca/gprof2dot/pull/101  **Full Changelog**: https://github.com/jrfonseca/gprof2dot/compare/2024.06.06...2025.04.14 |
| `2025.04.14` | 2025-04-14 | Low | ## What's Changed * Remove "%3" tooltip in SVG output by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/101 * Add an option to specify time format by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/102  ## New Contributors * @eltoder made their first contribution in https://github.com/jrfonseca/gprof2dot/pull/101  **Full Changelog**: https://github.com/jrfonseca/gprof2dot/compare/2024.06.06...2025.04.14 |
| `2025.04.14` | 2025-04-14 | Low | ## What's Changed * Remove "%3" tooltip in SVG output by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/101 * Add an option to specify time format by @eltoder in https://github.com/jrfonseca/gprof2dot/pull/102  ## New Contributors * @eltoder made their first contribution in https://github.com/jrfonseca/gprof2dot/pull/101  **Full Changelog**: https://github.com/jrfonseca/gprof2dot/compare/2024.06.06...2025.04.14 |

## Citation

- HTML: https://www.freshcrate.ai/projects/gprof2dot
- Markdown: https://www.freshcrate.ai/projects/gprof2dot.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/gprof2dot/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
