Skip to content

Commit

Permalink
Add flamegraph to profiling GTG for performance documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Neui authored and diegogangl committed May 17, 2021
1 parent 1f8949c commit 56c940e
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions docs/contributors/profiling GTG for performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ There are various tools to profile (measure) performance and identify problems.
* cProfile
* gprof2dot
* sysprof
* flameprof

# Profiling with cProfile

Python's [cProfile](http://docs.python.org/library/profile.html) allows profiling the whole GTG app. Do this following:

$ python3 -m cProfile -o gtg.prof ./gtg
./launch.sh -p 'python3 -m cProfile -o gtg.prof'

Let GTG launch. Quit, and do the following to parse the results:

Expand Down Expand Up @@ -54,13 +55,27 @@ This should display profiling results, sorted by cumulative time, and displaying

Install [gprof2dot](https://github.com/jrfonseca/gprof2dot), then execute:

./scripts/debug.sh -p
./launch.sh -p 'python3 -m cProfile -o gtg.prof'
python gprof2dot.py -f pstats gtg.prof | dot -Tpng -o output.png

...and watch the resulting pretty image!

![](https://wiki.gnome.org/Apps/GTG/development?action=AttachFile&do=get&target=profile.png)
![Generated image](https://wiki.gnome.org/Apps/GTG/development?action=AttachFile&do=get&target=profile.png)

# Sysprof

Sysprof is a really cool graphical user interface for system-wide (or application-specific) profiling. If it can be useful for profiling GTG, someone should document how to use it here...
Sysprof is a really cool graphical user interface for system-wide (or application-specific) profiling.
If it can be useful for profiling GTG, someone should document how to use it here...

# flameprof (flamegraph)

You can use [flameprof](https://pypi.org/project/flameprof/) to generate
an [flamegraph](https://www.brendangregg.com/flamegraphs.html), which roughly
shows what GTG does over time.

```sh
./launch.sh -p 'python3 -m cProfile -o gtg.prof'
flameprof -o gtg.svg gtg.prof
```

![Generated image (not GTG)](https://raw.githubusercontent.com/brendangregg/FlameGraph/master/example-perf.svg)

0 comments on commit 56c940e

Please sign in to comment.