]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Correct Profile class usage example. Addresses issue #18033.
authorSenthil Kumaran <senthil@uthcode.com>
Sun, 8 Sep 2013 00:51:58 +0000 (17:51 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Sun, 8 Sep 2013 00:51:58 +0000 (17:51 -0700)
Patch contributed by Olivier Hervieu and Dmi Baranov.

Doc/library/profile.rst

index 3f2a02dca427d1000593d1a4a09394c29a0ea74d..aefc024d40e24879a0a85a7a2d413793de2d5122 100644 (file)
@@ -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()