Commit 9eb94e6b authored by Thibault Saunier's avatar Thibault Saunier

pitivi: Add support for easy profiling the app

And document it.
Reviewed-by: default avatarAlex Băluț <&lt;;>
Differential Revision:
parent 23c05efd
......@@ -18,6 +18,7 @@
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
import cProfile
import os
import sys
import signal
......@@ -155,4 +156,11 @@ if __name__ == "__main__":
# We do these checks on every startup (even outside the dev environment, for
# soft deps); doing imports and gst registry checks has near-zero cost.
run_profile = os.environ.get("PITIVI_PROFILING", False)
if run_profile:
prof = cProfile.Profile()
res = prof.runcall(_run_pitivi)
......@@ -250,3 +250,29 @@ The name of a callback method should:
You can guess the order of the imported modules by looking at some py files.
The pre-commit hook has authority in this case as it will reorder the imports
if the order is not good.
## Profiling Pitivi
To profile a pitivi run, simply set the PITIVI_PROFILING environment variable to 1, like so:
A file named `pitivi-runstats` will be created in the current directory, a handy tool to examine it is ``, install it with:
$ pip install gprof2dot
Then run:
$ gprof2dot -f pstats pitivi-runstats | dot -Tsvg -o profile.svg
You can then inspect the call tree profile with your preferred image viewer:
$ xdg-open profile.svg
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment