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.
--- 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()