From: Senthil Kumaran Date: Sun, 8 Sep 2013 00:51:58 +0000 (-0700) Subject: Correct Profile class usage example. Addresses issue #18033. X-Git-Tag: v3.4.0a3~27^2~19^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=21101f7038331984eee88fb6f876a3c6e2c3dfbb;p=thirdparty%2FPython%2Fcpython.git Correct Profile class usage example. Addresses issue #18033. Patch contributed by Olivier Hervieu and Dmi Baranov. --- diff --git a/Doc/library/profile.rst b/Doc/library/profile.rst index 3f2a02dca427..aefc024d40e2 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()