@@ -23,16 +23,17 @@ from .common import (
)
from .request import wsgirequest
from .. import (
encoding,
error,
hg,
hook,
+ profiling,
repoview,
templatefilters,
templater,
ui as uimod,
util,
)
from . import (
@@ -300,18 +301,19 @@ class hgweb(object):
def run_wsgi(self, req):
"""Internal method to run the WSGI application.
This is typically only called by Mercurial. External consumers
should be using instances of this class as the WSGI application.
"""
with self._obtainrepo() as repo:
- for r in self._runwsgi(req, repo):
- yield r
+ with profiling.maybeprofile(repo.ui):
+ for r in self._runwsgi(req, repo):
+ yield r
def _runwsgi(self, req, repo):
rctx = requestcontext(self, repo)
# This state is global across all threads.
encoding.encoding = rctx.config('web', 'encoding', encoding.encoding)
rctx.repo.ui.environ = req.env
@@ -26,16 +26,17 @@ from .common import (
staticfile,
)
from .request import wsgirequest
from .. import (
encoding,
error,
hg,
+ profiling,
scmutil,
templater,
ui as uimod,
util,
)
from . import (
hgweb_mod,
@@ -212,17 +213,19 @@ class hgwebdir(object):
allow_read = ui.configlist('web', 'allow_read', untrusted=True)
# by default, allow reading if no allow_read option has been set
if (not allow_read) or ismember(ui, user, allow_read):
return True
return False
def run_wsgi(self, req):
- return self._runwsgi(req)
+ with profiling.maybeprofile(self.ui):
+ for r in self._runwsgi(req):
+ yield r
def _runwsgi(self, req):
try:
self.refresh()
virtual = req.env.get("PATH_INFO", "").strip('/')
tmpl = self.templater(req)
ctype = tmpl('mimetype', encoding=encoding.encoding)
@@ -26,9 +26,23 @@ test --profile
$ hg --profile st 2>../out
$ grep 'events: Ticks' ../out > /dev/null || cat ../out
$ hg --profile --config profiling.output=../out st
$ grep 'events: Ticks' ../out > /dev/null || cat ../out
#endif
+#if lsprof serve
+
+Profiling of HTTP requests works
+
+ $ hg --profile --config profiling.format=text --config profiling.output=../profile.log serve -d -p $HGPORT --pid-file ../hg.pid -A ../access.log
+ $ cat ../hg.pid >> $DAEMON_PIDS
+ $ hg -q clone -U http://localhost:$HGPORT ../clone
+
+A single profile is logged because file logging doesn't append
+ $ grep CallCount ../profile.log | wc -l
+ 1
+
+#endif
+
$ cd ..