equal
deleted
inserted
replaced
150 def __init__(self, ui): |
150 def __init__(self, ui): |
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._entered = False |
|
156 self._started = False |
155 |
157 |
156 def __enter__(self): |
158 def __enter__(self): |
|
159 self._entered = True |
|
160 self.start() |
|
161 |
|
162 def start(self): |
|
163 """Start profiling. |
|
164 |
|
165 The profiling will stop at the context exit. |
|
166 |
|
167 If the profiler was already started, this has no effect.""" |
|
168 if not self._entered: |
|
169 raise error.ProgrammingError() |
|
170 if self._started: |
|
171 return |
|
172 self._started = True |
157 profiler = encoding.environ.get('HGPROF') |
173 profiler = encoding.environ.get('HGPROF') |
158 proffn = None |
174 proffn = None |
159 if profiler is None: |
175 if profiler is None: |
160 profiler = self._ui.config('profiling', 'type', default='stat') |
176 profiler = self._ui.config('profiling', 'type', default='stat') |
161 if profiler not in ('ls', 'stat', 'flame'): |
177 if profiler not in ('ls', 'stat', 'flame'): |