ProfilingDjango: runserver-profiler.diff
File runserver-profiler.diff, 1.3 KB (added by , 19 years ago) |
---|
-
django/core/management.py
925 925 sys.stderr.write(s.read()) 926 926 sys.exit(1) 927 927 928 import hotshot, time, os 929 def make_profiler_handler(inner_handler): 930 def handler(environ, start_response): 931 profname = "%s.%.3f.prof" % (environ['PATH_INFO'].strip("/").replace('/', '.'), time.time()) 932 profname = os.path.join('/tmp', profname) 933 prof = hotshot.Profile(profname) 934 return prof.runcall(inner_handler, environ, start_response) 935 return handler 936 928 937 def runserver(addr, port): 929 938 "Starts a lightweight Web server for development." 930 939 from django.core.servers.basehttp import run, AdminMediaHandler, WSGIServerException … … 942 951 print "Development server is running at http://%s:%s/" % (addr, port) 943 952 print "Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows)." 944 953 try: 945 run(addr, int(port), AdminMediaHandler(WSGIHandler()))954 run(addr, int(port), make_profiler_handler(AdminMediaHandler(WSGIHandler()))) 946 955 except WSGIServerException, e: 947 956 # Use helpful error messages instead of ugly tracebacks. 948 957 ERRORS = {