Mercurial > public > mercurial-scm > hg
comparison mercurial/profiling.py @ 32786:0ead06d54ffe
profile: make the contextmanager object available to the callers
This will allow calling methods on the object in the code using the context
manager.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 09 Jun 2017 11:42:45 +0100 |
parents | 37ec8f24d912 |
children | eede022fc142 |
comparison
equal
deleted
inserted
replaced
32785:37ec8f24d912 | 32786:0ead06d54ffe |
---|---|
158 | 158 |
159 def __enter__(self): | 159 def __enter__(self): |
160 self._entered = True | 160 self._entered = True |
161 if self._enabled: | 161 if self._enabled: |
162 self.start() | 162 self.start() |
163 return self | |
163 | 164 |
164 def start(self): | 165 def start(self): |
165 """Start profiling. | 166 """Start profiling. |
166 | 167 |
167 The profiling will stop at the context exit. | 168 The profiling will stop at the context exit. |
228 | 229 |
229 The purpose of this context manager is to make calling code simpler: | 230 The purpose of this context manager is to make calling code simpler: |
230 just use a single code path for calling into code you may want to profile | 231 just use a single code path for calling into code you may want to profile |
231 and this function determines whether to start profiling. | 232 and this function determines whether to start profiling. |
232 """ | 233 """ |
233 with profile(ui, enabled=ui.configbool('profiling', 'enabled')): | 234 with profile(ui, enabled=ui.configbool('profiling', 'enabled')) as p: |
234 yield | 235 yield p |