import time
#----------------------------------------------------------------------
def fast():
""""""
print("I run fast!")
#----------------------------------------------------------------------
def slow():
""""""
time.sleep(3)
print("I run slow!")
#----------------------------------------------------------------------
def medium():
""""""
time.sleep(0.5)
print("I run a little slowly...")
#----------------------------------------------------------------------
def main():
""""""
fast()
slow()
medium()
if __name__ == '__main__':
main()
python -m cProfile -o output.txt ptest.py
import pstats
p = pstats.Stats("output.txt")
p.strip_dirs().sort_stats(-1).print_stats() # 排序并打印