diff options
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/profile.rst | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst index a6dc56f..5dc0b2f 100644 --- a/Doc/library/profile.rst +++ b/Doc/library/profile.rst @@ -262,6 +262,16 @@ functions: ps.print_stats() print(s.getvalue()) + The :class:`Profile` class can also be used as a context manager (see + :ref:`typecontextmanager`):: + + import cProfile + + with cProfile.Profile() as pr: + # ... do something ... + + pr.print_stats() + .. method:: enable() Start collecting profiling data. |