(original) (raw)

changeset: 85603:88182b388bae parent: 85600:dea4c70cc8d1 parent: 85602:ab4d3ccb92e6 user: Senthil Kumaran senthil@uthcode.com date: Sat Sep 07 17:52:38 2013 -0700 description: merge from 3.3 Correct Profile class usage example. Addresses issue #18033. Patch contributed by Olivier Hervieu and Dmi Baranov. diff -r dea4c70cc8d1 -r 88182b388bae Doc/library/profile.rst --- a/Doc/library/profile.rst Sat Sep 07 17:41:01 2013 -0700 +++ b/Doc/library/profile.rst Sat Sep 07 17:52:38 2013 -0700 @@ -247,11 +247,13 @@ 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() /senthil@uthcode.com