Mercurial > hg-stable
changeset 42386:a09829e14fc0
perf: make sure to explicitly disable any profiler after the first iteration
The current code work, because of some edge behavior of the `profile` class. We
make it explicit that the profiler is not in effect more than once.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 23 May 2019 19:05:39 +0200 |
parents | b02f3aa2fab5 |
children | 92f584065b4f |
files | contrib/perf.py |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/perf.py Wed May 22 16:20:34 2019 -0700 +++ b/contrib/perf.py Thu May 23 19:05:39 2019 +0200 @@ -275,6 +275,8 @@ def __exit__(self, *args): pass +NOOPCTX = noop() + def gettimer(ui, opts=None): """return a timer function and formatter: (timer, formatter) @@ -405,7 +407,7 @@ begin = util.timer() count = 0 if profiler is None: - profiler = noop() + profiler = NOOPCTX for i in xrange(prerun): if setup is not None: setup() @@ -417,6 +419,7 @@ with profiler: with timeone() as item: r = func() + profiler = NOOPCTX count += 1 results.append(item[0]) cstop = util.timer()