perf: make sure to explicitly disable any profiler after the first iteration
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 23 May 2019 19:05:39 +0200
changeset 42364 a09829e14fc0
parent 42363 b02f3aa2fab5
child 42365 92f584065b4f
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.
contrib/perf.py
--- 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()