scripts: Add --profile-dot to run_profile.

This commit is contained in:
Florian Bruhin 2015-05-21 07:45:20 +02:00
parent 43898ebb71
commit ee0eabc202

View File

@ -39,18 +39,29 @@ if '--profile-keep' in sys.argv:
profilefile = os.path.join(os.getcwd(), 'profile') profilefile = os.path.join(os.getcwd(), 'profile')
else: else:
profilefile = os.path.join(tempdir, 'profile') profilefile = os.path.join(tempdir, 'profile')
if '--profile-noconv' in sys.argv: if '--profile-noconv' in sys.argv:
sys.argv.remove('--profile-noconv') sys.argv.remove('--profile-noconv')
noconv = True noconv = True
else: else:
noconv = False noconv = False
if '--profile-dot' in sys.argv:
sys.argv.remove('--profile-dot')
dot = True
else:
dot = False
callgraphfile = os.path.join(tempdir, 'callgraph') callgraphfile = os.path.join(tempdir, 'callgraph')
profiler = cProfile.Profile() profiler = cProfile.Profile()
profiler.run('qutebrowser.qutebrowser.main()') profiler.run('qutebrowser.qutebrowser.main()')
profiler.dump_stats(profilefile) profiler.dump_stats(profilefile)
if not noconv: if not noconv:
subprocess.call(['pyprof2calltree', '-k', '-i', profilefile, if dot:
'-o', callgraphfile]) 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) shutil.rmtree(tempdir)