Kaydet (Commit) cb7e5fa9 authored tarafından Senthil Kumaran's avatar Senthil Kumaran

Correct Profile class usage example. Addresses issue #18033 .

Patch contributed by Olivier Hervieu and Dmi Baranov.
üst 2646e675
......@@ -267,14 +267,16 @@ functions:
Directly using the :class:`Profile` class allows formatting profile results
without writing the profile data to a file::
import cProfile, pstats, io
import cProfile, pstats, StringIO
pr = cProfile.Profile()
pr.enable()
... do something ...
# ... do something ...
pr.disable()
s = io.StringIO()
ps = pstats.Stats(pr, stream=s)
ps.print_results()
s = StringIO.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print s.getvalue()
.. method:: enable()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment