##// END OF EJS Templates
pull request: use unionrepo instead of outgoing...
pull request: use unionrepo instead of outgoing This makes it possible to look the 'moving target' symbols up in the right repo. Using a revset with the right revisions also removes the need for pruning changesets that are outside the requested range. It will also not be confused by changesets that for some reason has been pulled to the repo but haven't been merged yet. They are going to be 'merged' by the 'pull' request and should thus be a part of what is reviewed.

File last commit:

r2215:2c2bdaec codereview
r3303:ae5ac36c beta
Show More
profiler.py
60 lines | 1.6 KiB | text/x-python | PythonLexer
renamed project to rhodecode
r547 from __future__ import with_statement
code-review initial
r2215 import gc
import objgraph
renamed project to rhodecode
r547 import cProfile
import pstats
import cgi
import pprint
import threading
from StringIO import StringIO
pep8ify
r1307
renamed project to rhodecode
r547 class ProfilingMiddleware(object):
def __init__(self, app):
self.lock = threading.Lock()
self.app = app
source code cleanup: remove trailing white space, normalize file endings
r1203
renamed project to rhodecode
r547 def __call__(self, environ, start_response):
with self.lock:
profiler = cProfile.Profile()
pep8ify
r1307
renamed project to rhodecode
r547 def run_app(*a, **kw):
self.response = self.app(environ, start_response)
profiler.runcall(run_app, environ, start_response)
profiler.snapshot_stats()
stats = pstats.Stats(profiler)
code-review initial
r2215 stats.sort_stats('calls') #cummulative
renamed project to rhodecode
r547
# Redirect output
out = StringIO()
stats.stream = out
stats.print_stats()
resp = ''.join(self.response)
# Lets at least only put this on html-like responses.
if resp.strip().startswith('<'):
## The profiling info is just appended to the response.
## Browsers don't mind this.
pep8ify
r1307 resp += ('<pre style="text-align:left; '
'border-top: 4px dashed red; padding: 1em;">')
renamed project to rhodecode
r547 resp += cgi.escape(out.getvalue(), True)
source code cleanup: remove trailing white space, normalize file endings
r1203
code-review initial
r2215 ct = objgraph.show_most_common_types()
print ct
resp += ct if ct else '---'
renamed project to rhodecode
r547 output = StringIO()
pprint.pprint(environ, output, depth=3)
source code cleanup: remove trailing white space, normalize file endings
r1203
renamed project to rhodecode
r547 resp += cgi.escape(output.getvalue(), True)
resp += '</pre>'
source code cleanup: remove trailing white space, normalize file endings
r1203
renamed project to rhodecode
r547 return resp