From 033aa34404aca042b81ef5aa500c479b11a0dc6a Mon Sep 17 00:00:00 2001 From: arza Date: Tue, 24 Sep 2019 19:34:03 +0300 Subject: [PATCH 1/3] run_profile: Set default profile file for --profile-tool=none Fixes "TypeError: join() argument must be str or bytes, not 'NoneType'". --- scripts/dev/run_profile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/dev/run_profile.py b/scripts/dev/run_profile.py index ff13da7a3..2e7773716 100755 --- a/scripts/dev/run_profile.py +++ b/scripts/dev/run_profile.py @@ -49,6 +49,7 @@ def parse_args(): default='snakeviz', help="The tool to use to view the profiling data") parser.add_argument('--profile-file', metavar='FILE', action='store', + default="profile_data", help="The filename to use with --profile-tool=none") parser.add_argument('--profile-test', action='store_true', help="Run pytest instead of qutebrowser") From 96b76190cff8fa5a1d1c2983f1dfce92d4488532 Mon Sep 17 00:00:00 2001 From: arza Date: Tue, 24 Sep 2019 23:13:21 +0300 Subject: [PATCH 2/3] run_profile: Print written filename for --profile-tool=none --- scripts/dev/run_profile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev/run_profile.py b/scripts/dev/run_profile.py index 2e7773716..443bc676d 100755 --- a/scripts/dev/run_profile.py +++ b/scripts/dev/run_profile.py @@ -81,7 +81,7 @@ def main(): profiler.dump_stats(profilefile) if args.profile_tool == 'none': - pass + print("Profile data written to {}".format(profilefile)) elif args.profile_tool == 'gprof2dot': # yep, shell=True. I know what I'm doing. subprocess.run( From 23942e30b387b14fcab336c1ce6637f2bd535cd5 Mon Sep 17 00:00:00 2001 From: arza Date: Wed, 25 Sep 2019 00:25:43 +0300 Subject: [PATCH 3/3] Improve contributing.asciidoc for run_profile.py --- doc/contributing.asciidoc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc index 84e9a17d0..4d0cedbeb 100644 --- a/doc/contributing.asciidoc +++ b/doc/contributing.asciidoc @@ -183,17 +183,21 @@ tox -e py35-cov -- tests/unit/browser/test_webelem.py Profiling ~~~~~~~~~ -In the _scripts/_ subfolder there's a `run_profile.py` which profiles the code -and shows a graphical representation of what takes how much time. +In the _scripts/dev/_ subfolder there's `run_profile.py` which profiles the +code and shows a graphical representation of what takes how much time. It uses the built-in Python -https://docs.python.org/3.6/library/profile.html[cProfile] module and can show -the output in four different ways: +https://docs.python.org/3/library/profile.html[cProfile] module. It launches a +qutebrowser instance, waits for it to exit and then shows the graph. -* Raw profile file (`--profile-tool=none`) +Available methods for visualization are: + +* https://jiffyclub.github.io/snakeviz/[SnakeViz] (`--profile-tool=snakeviz`, the default) * https://pypi.python.org/pypi/pyprof2calltree/[pyprof2calltree] and http://kcachegrind.sourceforge.net/html/Home.html[KCacheGrind] (`--profile-tool=kcachegrind`) -* https://jiffyclub.github.io/snakeviz/[SnakeViz] (`--profile-tool=snakeviz`) -* https://github.com/jrfonseca/gprof2dot[gprof2dot] (needs `dot` from http://graphviz.org/[Graphviz] and http://feh.finalrewind.org/[feh]) +* https://github.com/jrfonseca/gprof2dot[gprof2dot] (`--profile-tool=gprof2dot`, needs `dot` from http://graphviz.org/[Graphviz] and http://feh.finalrewind.org/[feh]) +* https://github.com/nschloe/tuna[tuna] (`--profile-tool=tuna`) + +You can also save the binary profile data to a file (`--profile-tool=none`). Debugging ~~~~~~~~~