瀏覽代碼

HUE-500. Add information about Hue profiling to README.rst

Jon Natkins 14 年之前
父節點
當前提交
6703da846c
共有 1 個文件被更改,包括 33 次插入0 次删除
  1. 33 0
      README.rst

+ 33 - 0
README.rst

@@ -181,3 +181,36 @@ the python bindings like so::
 .. note::
     This file is in reStructuredText. You may run
     ``rst2html README.rst > README.html`` to produce a HTML.
+
+
+Profiling Hue Apps
+==================
+Hue has a profiling system built in, which can be used to analyze server-side
+performance of applications.  To enable profiling::
+
+    $ build/env/bin/hue runprofileserver
+
+Then, access the page that you want to profile.  This will create files like
+/tmp/useradmin.users.000072ms.2011-02-21T13:03:39.745851.prof.  The format for
+the file names is /tmp/<app_module>.<page_url>.<time_taken>.<timestamp>.prof.
+
+Hue uses the hotshot profiling library for instrumentation.  The documentation
+for this library is located at: http://docs.python.org/library/hotshot.html.
+
+To make use of the profiling data quickly, you can create a script that does
+the following::
+
+    #!/usr/bin/python
+    import hotshot.stats
+    import sys
+
+    stats = hotshot.stats.load(sys.argv[1])
+    stats.sort_stats('cumulative', 'calls')
+    stats.print_stats(100)
+
+This script takes in a .prof file, and orders function calls by the cumulative
+time spent in that function, followed by the number of times the function was
+called, and then prints out the top 100 time-wasters.  For information on the
+other stats available, take a look at this website:
+http://docs.python.org/library/profile.html#pstats.Stats
+