##// END OF EJS Templates
profile: introduce a knob to control if the context is actually profiling...
marmoute -
r32785:37ec8f24 default
parent child Browse files
Show More
@@ -147,16 +147,18 b' class profile(object):'
147 147 Profiling is active when the context manager is active. When the context
148 148 manager exits, profiling results will be written to the configured output.
149 149 """
150 def __init__(self, ui):
150 def __init__(self, ui, enabled=True):
151 151 self._ui = ui
152 152 self._output = None
153 153 self._fp = None
154 154 self._profiler = None
155 self._enabled = enabled
155 156 self._entered = False
156 157 self._started = False
157 158
158 159 def __enter__(self):
159 160 self._entered = True
161 if self._enabled:
160 162 self.start()
161 163
162 164 def start(self):
@@ -228,8 +230,5 b' def maybeprofile(ui):'
228 230 just use a single code path for calling into code you may want to profile
229 231 and this function determines whether to start profiling.
230 232 """
231 if ui.configbool('profiling', 'enabled'):
232 with profile(ui):
233 with profile(ui, enabled=ui.configbool('profiling', 'enabled')):
233 234 yield
234 else:
235 yield
General Comments 0
You need to be logged in to leave comments. Login now