diff options
Diffstat (limited to 'Doc/library/profile.rst')
-rw-r--r-- | Doc/library/profile.rst | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst index 3f2a02d..aefc024 100644 --- a/Doc/library/profile.rst +++ b/Doc/library/profile.rst @@ -247,11 +247,13 @@ functions: import cProfile, pstats, io pr = cProfile.Profile() pr.enable() - ... do something ... + # ... do something ... pr.disable() s = io.StringIO() - ps = pstats.Stats(pr, stream=s) - ps.print_results() + sortby = 'cumulative' + ps = pstats.Stats(pr, stream=s).sort_stats(sortby) + ps.print_stats() + print(s.getvalue()) .. method:: enable() |