Commit 4e572496 authored by Senthil Kumaran's avatar Senthil Kumaran

Correct Profile class usage example. Addresses issue #18033.

Patch contributed by Olivier Hervieu and Dmi Baranov.
parent e3405b4f
...@@ -247,11 +247,13 @@ functions: ...@@ -247,11 +247,13 @@ functions:
import cProfile, pstats, io import cProfile, pstats, io
pr = cProfile.Profile() pr = cProfile.Profile()
pr.enable() pr.enable()
... do something ... # ... do something ...
pr.disable() pr.disable()
s = io.StringIO() s = io.StringIO()
ps = pstats.Stats(pr, stream=s) sortby = 'cumulative'
ps.print_results() ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
print(s.getvalue())
.. method:: enable() .. 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