# HG changeset patch # User Pierre-Yves David <pierre-yves.da...@octobus.net> # Date 1558631139 -7200 # Thu May 23 19:05:39 2019 +0200 # Node ID b6d5cc6ccb0a14d094590a42bdaaab41f74ed945 # Parent b02f3aa2fab572dac4deb5271d349d1cdceedf96 # EXP-Topic perf-followup # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r b6d5cc6ccb0a 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. diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -275,6 +275,8 @@ class noop(object): def __exit__(self, *args): pass +NOOPCTX = noop() + def gettimer(ui, opts=None): """return a timer function and formatter: (timer, formatter) @@ -405,7 +407,7 @@ def _timer(fm, func, setup=None, title=N 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 @@ def _timer(fm, func, setup=None, title=N with profiler: with timeone() as item: r = func() + profiler = NOOPCTX count += 1 results.append(item[0]) cstop = util.timer() _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel