summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2013-09-08 00:52:38 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2013-09-08 00:52:38 (GMT)
commitb1424a2908f03ad1a41c9a845dd9782e6643fbb9 (patch)
treea4100fb048a37eb39a53bf001b331f024815e979
parent04fd9dd52bc81041126cb8df86a5e7629113a193 (diff)
parent21101f7038331984eee88fb6f876a3c6e2c3dfbb (diff)
downloadcpython-b1424a2908f03ad1a41c9a845dd9782e6643fbb9.zip
cpython-b1424a2908f03ad1a41c9a845dd9782e6643fbb9.tar.gz
cpython-b1424a2908f03ad1a41c9a845dd9782e6643fbb9.tar.bz2
merge from 3.3
Correct Profile class usage example. Addresses issue #18033. Patch contributed by Olivier Hervieu and Dmi Baranov.
-rw-r--r--Doc/library/profile.rst8
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()