[LNT] r240557 - Add --profiler-dir and --profiler-file options to lnt runserver.

Kristof Beyls kristof.beyls at arm.com
Wed Jun 24 10:32:08 PDT 2015

Author: kbeyls
Date: Wed Jun 24 12:32:08 2015
New Revision: 240557

URL: http://llvm.org/viewvc/llvm-project?rev=240557&view=rev
Add --profiler-dir and --profiler-file options to lnt runserver.

--profiler-file=profile.log allows overriding the default file
the profile information is stored to.

--profiler-dir=profile_dir lets the profiler store more detailed
information, in a separate file per request, into the specified
directory. These files contain call graph profiles, which you
don't get from --profiler-file profiles. These call graphs can
be visualized with commands like:
$ pip install gprof2dot
$ gprof2dot -f pstats profile_dir/POST.submitRun.000591ms.1435075964.prof |\
  dot -Tsvg > submitRun.svg


Modified: lnt/trunk/lnt/lnttool/main.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/lnttool/main.py?rev=240557&r1=240556&r2=240557&view=diff
--- lnt/trunk/lnt/lnttool/main.py (original)
+++ lnt/trunk/lnt/lnttool/main.py Wed Jun 24 12:32:08 2015
@@ -40,6 +40,13 @@ view the results.\
                       action="store_true", help="use WSGI reload monitor")
     parser.add_option("", "--debugger", dest="debugger", default=False,
                       action="store_true", help="use WSGI debugger")
+    parser.add_option("", "--profiler-file", dest="profiler_file",
+                      help="file to dump profile info to [%default]",
+                      default="profiler.log")
+    parser.add_option("", "--profiler-dir", dest="profiler_dir",
+                      help="pstat.Stats files are saved to this directory " \
+                          +"[%default]",
+                      default=None)
     parser.add_option("", "--profiler", dest="profiler", default=False,
                       action="store_true", help="enable WSGI profiler")
     parser.add_option("", "--show-sql", dest="show_sql", default=False,
@@ -79,8 +86,12 @@ view the results.\
     if opts.debugger:
         app.debug = True
     if opts.profiler:
+        if opts.profiler_dir:
+            if not os.path.isdir(opts.profiler_dir):
+                os.mkdir(opts.profiler_dir)
         app.wsgi_app = werkzeug.contrib.profiler.ProfilerMiddleware(
-            app.wsgi_app, stream = open('profiler.log', 'w'))
+            app.wsgi_app, stream = open(opts.profiler_file, 'w'),
+            profile_dir = opts.profiler_dir)
     app.run(opts.hostname, opts.port,
             use_reloader = opts.reloader,
             use_debugger = opts.debugger,

More information about the llvm-commits mailing list