| This module provides a nicer interface to the :mod:`_hotshot` C module. Hotshot |
| is a replacement for the existing :mod:`profile` module. As it's written mostly |
| in C, it should result in a much smaller performance impact than the existing |
| :mod:`profile` module. |
| |
| .. note:: |
| |
| The :mod:`hotshot` module focuses on minimizing the overhead while profiling, at |
n | the expense of long data post-processing times. For common usages it is |
n | the expense of long data post-processing times. For common usage it is |
| recommended to use :mod:`cProfile` instead. :mod:`hotshot` is not maintained and |
| might be removed from the standard library in the future. |
| |
| .. versionchanged:: 2.5 |
n | the results should be more meaningful than in the past: the timing core |
n | The results should be more meaningful than in the past: the timing core |
| contained a critical bug. |
| |
| .. warning:: |
| |
| The :mod:`hotshot` profiler does not yet work well with threads. It is useful to |
| use an unthreaded script to run the profiler over the code you're interested in |
| measuring if at all possible. |
| |
| .. _hotshot-objects: |
| |
| Profile Objects |
| --------------- |
| |
| Profile objects have the following methods: |
| |
| |
n | .. method:: XXX Class.addinfo(key, value) |
n | .. method:: Profile.addinfo(key, value) |
| |
| Add an arbitrary labelled value to the profile output. |
| |
| |
n | .. method:: XXX Class.close() |
n | .. method:: Profile.close() |
| |
| Close the logfile and terminate the profiler. |
| |
| |
n | .. method:: XXX Class.fileno() |
n | .. method:: Profile.fileno() |
| |
| Return the file descriptor of the profiler's log file. |
| |
| |
n | .. method:: XXX Class.run(cmd) |
n | .. method:: Profile.run(cmd) |
| |
| Profile an :keyword:`exec`\ -compatible string in the script environment. The |
| globals from the :mod:`__main__` module are used as both the globals and locals |
| for the script. |
| |
| |
n | .. method:: XXX Class.runcall(func, *args, **keywords) |
n | .. method:: Profile.runcall(func, *args, **keywords) |
| |
| Profile a single call of a callable. Additional positional and keyword arguments |
| may be passed along; the result of the call is returned, and exceptions are |
| allowed to propagate cleanly, while ensuring that profiling is disabled on the |
| way out. |
| |
| |
n | .. method:: XXX Class.runctx(cmd, globals, locals) |
n | .. method:: Profile.runctx(cmd, globals, locals) |
| |
| Evaluate an :keyword:`exec`\ -compatible string in a specific environment. The |
| string is compiled before profiling begins. |
| |
| |
n | .. method:: XXX Class.start() |
n | .. method:: Profile.start() |
| |
| Start the profiler. |
| |
| |
t | .. method:: XXX Class.stop() |
t | .. method:: Profile.stop() |
| |
| Stop the profiler. |
| |
| |
| Using hotshot data |
| ------------------ |
| |
| .. module:: hotshot.stats |