Django

Code

root/django/trunk/django/core/handlers/profiler-hotshot.py

Revision 4265, 0.9 kB (checked in by adrian, 2 years ago)

Fixed #3191 -- Set 'svn:eol-style native' on the files that didn't have it. Thanks, jjl@pobox.com

  • Property svn:eol-style set to native
  • Property svn:keywords set to LastChangedRevision
Line 
1 import hotshot, time, os
2 from django.core.handlers.modpython import ModPythonHandler
3
4 PROFILE_DATA_DIR = "/var/log/cmsprofile"
5
6 def handler(req):
7     '''
8     Handler that uses hotshot to store profile data.
9
10     Stores profile data in PROFILE_DATA_DIR.  Since hotshot has no way (that I
11     know of) to append profile data to a single file, each request gets its own
12     profile.  The file names are in the format <url>.<n>.prof where <url> is
13     the request path with "/" replaced by ".", and <n> is a timestamp with
14     microseconds to prevent overwriting files.
15
16     Use the gather_profile_stats.py script to gather these individual request
17     profiles into aggregated profiles by request path.
18     '''
19     profname = "%s.%.3f.prof" % (req.uri.strip("/").replace('/', '.'), time.time())
20     profname = os.path.join(PROFILE_DATA_DIR, profname)
21     prof = hotshot.Profile(profname)
22     return prof.runcall(ModPythonHandler(), req)
Note: See TracBrowser for help on using the browser.