mirror of https://github.com/python/cpython
Correct Profile class usage example. Addresses issue #18033.
Patch contributed by Olivier Hervieu and Dmi Baranov.
This commit is contained in:
parent
8ef519b24f
commit
21101f7038
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue