diff --git a/scripts/run_profile.py b/scripts/run_profile.py index 698407a23..8b0c85aae 100755 --- a/scripts/run_profile.py +++ b/scripts/run_profile.py @@ -39,18 +39,29 @@ if '--profile-keep' in sys.argv: profilefile = os.path.join(os.getcwd(), 'profile') else: profilefile = os.path.join(tempdir, 'profile') + if '--profile-noconv' in sys.argv: sys.argv.remove('--profile-noconv') noconv = True else: noconv = False +if '--profile-dot' in sys.argv: + sys.argv.remove('--profile-dot') + dot = True +else: + dot = False + callgraphfile = os.path.join(tempdir, 'callgraph') profiler = cProfile.Profile() profiler.run('qutebrowser.qutebrowser.main()') profiler.dump_stats(profilefile) if not noconv: - subprocess.call(['pyprof2calltree', '-k', '-i', profilefile, - '-o', callgraphfile]) + if dot: + subprocess.call('gprof2dot -f pstats profile | dot -Tpng | feh -F -', + shell=True) # yep, shell=True. I know what I'm doing. + else: + subprocess.call(['pyprof2calltree', '-k', '-i', profilefile, + '-o', callgraphfile]) shutil.rmtree(tempdir)