ProfilingDjango: runserver-profiler2.diff
File runserver-profiler2.diff, 1.2 KB (added by , 18 years ago) |
---|
-
management.py
7 7 from optparse import OptionParser 8 8 from django.utils import termcolors 9 9 10 import hotshot, time, os 11 def make_profiler_handler(inner_handler): 12 def handler(environ, start_response): 13 profname = "%s.%.3f.prof" % (environ['PATH_INFO'].strip("/").replace('/', '.'), time.time()) 14 profname = os.path.join('/tmp', profname) 15 prof = hotshot.Profile(profname) 16 return prof.runcall(inner_handler, environ, start_response) 17 return handler 18 10 19 # For Python 2.3 11 20 if not hasattr(__builtins__, 'set'): 12 21 from sets import Set as set … … 1188 1197 try: 1189 1198 import django 1190 1199 path = admin_media_dir or django.__path__[0] + '/contrib/admin/media' 1191 handler = AdminMediaHandler(WSGIHandler(), path)1200 handler = make_profiler_handler(AdminMediaHandler(WSGIHandler(), path)) 1192 1201 run(addr, int(port), handler) 1193 1202 except WSGIServerException, e: 1194 1203 # Use helpful error messages instead of ugly tracebacks.