From 4e57249645a95350dde04e732289dd5a33e49600 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran <senthil@uthcode.com> Date: Sat, 7 Sep 2013 17:51:58 -0700 Subject: [PATCH] Correct Profile class usage example. Addresses issue #18033. Patch contributed by Olivier Hervieu and Dmi Baranov. --- Doc/library/profile.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst index 3f2a02dca42..aefc024d40e 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() -- 2.30.9