##// 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,17 +147,19 b' class profile(object):'
147 Profiling is active when the context manager is active. When the context
147 Profiling is active when the context manager is active. When the context
148 manager exits, profiling results will be written to the configured output.
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 self._ui = ui
151 self._ui = ui
152 self._output = None
152 self._output = None
153 self._fp = None
153 self._fp = None
154 self._profiler = None
154 self._profiler = None
155 self._enabled = enabled
155 self._entered = False
156 self._entered = False
156 self._started = False
157 self._started = False
157
158
158 def __enter__(self):
159 def __enter__(self):
159 self._entered = True
160 self._entered = True
160 self.start()
161 if self._enabled:
162 self.start()
161
163
162 def start(self):
164 def start(self):
163 """Start profiling.
165 """Start profiling.
@@ -228,8 +230,5 b' def maybeprofile(ui):'
228 just use a single code path for calling into code you may want to profile
230 just use a single code path for calling into code you may want to profile
229 and this function determines whether to start profiling.
231 and this function determines whether to start profiling.
230 """
232 """
231 if ui.configbool('profiling', 'enabled'):
233 with profile(ui, enabled=ui.configbool('profiling', 'enabled')):
232 with profile(ui):
233 yield
234 else:
235 yield
234 yield
General Comments 0
You need to be logged in to leave comments. Login now