diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -28,6 +28,7 @@ from .. import ( error, hg, hook, + profiling, repoview, templatefilters, templater, @@ -305,8 +306,9 @@ class hgweb(object): 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) diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -31,6 +31,7 @@ from .. import ( encoding, error, hg, + profiling, scmutil, templater, ui as uimod, @@ -217,7 +218,9 @@ class hgwebdir(object): 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: diff --git a/tests/test-profile.t b/tests/test-profile.t --- a/tests/test-profile.t +++ b/tests/test-profile.t @@ -31,4 +31,18 @@ test --profile #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 + \s*1 (re) + +#endif + $ cd ..