Changeset 513
- Timestamp:
- 10/05/08 21:06:06 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/oforgeplugin/share/cgi-bin/trac-profile.wsgi
r512 r513 5 5 # http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac 6 6 # http://trac.edgewall.org/wiki/TracModWSGI 7 import os 7 8 import sys 8 9 sys.stdout = sys.stderr 9 10 10 # disable postgres DB connection pooling 11 import trac.db.postgres_backend 12 trac.db.postgres_backend.PostgreSQLConnection.poolable = False 13 14 #from trac.web.main import dispatch_request as application 11 import hotshot, hotshot.stats 12 from cgi import parse_qs 15 13 16 14 # TODO: change this to a proper middleware wrapper 17 15 from trac.web.main import dispatch_request 18 16 def application(environ, start_response): 19 for k, v in sorted(environ.iteritems()): 20 print 'ENV Vars: %s = %s' % (k, v) 21 import hotshot, hotshot.stats 22 prof = hotshot.Profile("/tmp/wsgi.prof") 23 prof.runcall(dispatch_request,environ, start_response) 17 tempfilename = "/tmp/wsgi.prof-%s" % environ['UNIQUE_ID'] 18 prof = hotshot.Profile(tempfilename) 19 response = prof.runcall(dispatch_request,environ, start_response) 24 20 prof.close() 25 stats = hotshot.stats.load( "/tmp/wsgi.prof")26 #stats.strip_dirs()27 from cgi import parse_qs 21 stats = hotshot.stats.load(tempfilename) 22 os.remove(tempfilename) 23 28 24 args=parse_qs(environ['QUERY_STRING']) 29 25 arg_sort=args.get('PROFILE_SORT',['time'])[0] 30 26 arg_count=args.get('PROFILE_COUNT',[20])[0] 27 28 print 'Timings for %s'%environ['REQUEST_URI'] 29 # for k, v in sorted(environ.iteritems()): 30 # print 'ENV: %s = %s' % (k, v) 31 31 stats.sort_stats(arg_sort) 32 32 stats.print_stats(arg_count) 33 34 return response
Note: See TracChangeset
for help on using the changeset viewer.
