pyton性能分析器——pyinstrument

pyinstrument会把代码里运行耗时的部分给你找出来

  • 使用

pip install pyinstrument

import time
from pyinstrument import Profiler

def sleep_time():
    time.sleep(2)
    print('end')


profiler = Profiler()
profiler.start()

"""
要运行的内容
"""
sleep_time()

profiler.stop()
print(profiler.output_text(unicode=True, color=True))

posted @ 2021-09-19 23:42  三个零  阅读(365)  评论(0编辑  收藏  举报