summaryrefslogtreecommitdiffstats
path: root/google_appengine/lib/django/django/core/handlers/profiler-hotshot.py
diff options
context:
space:
mode:
Diffstat (limited to 'google_appengine/lib/django/django/core/handlers/profiler-hotshot.py')
-rwxr-xr-xgoogle_appengine/lib/django/django/core/handlers/profiler-hotshot.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/google_appengine/lib/django/django/core/handlers/profiler-hotshot.py b/google_appengine/lib/django/django/core/handlers/profiler-hotshot.py
new file mode 100755
index 0000000..6cf94b0
--- /dev/null
+++ b/google_appengine/lib/django/django/core/handlers/profiler-hotshot.py
@@ -0,0 +1,22 @@
+import hotshot, time, os
+from django.core.handlers.modpython import ModPythonHandler
+
+PROFILE_DATA_DIR = "/var/log/cmsprofile"
+
+def handler(req):
+ '''
+ Handler that uses hotshot to store profile data.
+
+ Stores profile data in PROFILE_DATA_DIR. Since hotshot has no way (that I
+ know of) to append profile data to a single file, each request gets its own
+ profile. The file names are in the format <url>.<n>.prof where <url> is
+ the request path with "/" replaced by ".", and <n> is a timestamp with
+ microseconds to prevent overwriting files.
+
+ Use the gather_profile_stats.py script to gather these individual request
+ profiles into aggregated profiles by request path.
+ '''
+ profname = "%s.%.3f.prof" % (req.uri.strip("/").replace('/', '.'), time.time())
+ profname = os.path.join(PROFILE_DATA_DIR, profname)
+ prof = hotshot.Profile(profname)
+ return prof.runcall(ModPythonHandler(), req)