Part of bzrlib.lsprof View In Hierarchy
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.
This hooks into threading and will record all calls made until stop() is called.
This unhooks from threading and cleans up the profiler, returning the gathered Stats object.
|Returns||A bzrlib.lsprof.Stats object.|