b.l.BzrProfiler(object) : class documentation

Part of bzrlib.lsprof View In Hierarchy

Bzr utility wrapper around Profiler.

For most uses the module level 'profile()' function will be suitable. However profiling when a simple wrapped function isn't available may be easier to accomplish using this class.

To use it, create a BzrProfiler and call start() on it. Some arbitrary time later call stop() to stop profiling and retrieve the statistics from the code executed in the interim.

Note that profiling involves a threading.Lock around the actual profiling. This is needed because profiling involves global manipulation of the python interpreter state. As such you cannot perform multiple profiles at once. Trying to do so will lock out the second profiler unless the global bzrlib.lsprof.BzrProfiler.profiler_block is set to 0. Setting it to 0 will cause profiling to fail rather than blocking.

Method start Start profiling.
Method stop Stop profiling.
Method _thread_profile Undocumented
def start(self):
Start profiling.

This hooks into threading and will record all calls made until stop() is called.

def stop(self):
Stop profiling.

This unhooks from threading and cleans up the profiler, returning the gathered Stats object.

ReturnsA bzrlib.lsprof.Stats object.
def _thread_profile(self, f, *args, **kwds):
API Documentation for Bazaar, generated by pydoctor at 2019-07-21 00:34:56.