繁体   English   中英

Python分析:在每行函数上花费的时间

[英]Python profiling: time spent on each line of function

我一直在研究配置文件中的示例,我在运行时已经进入了工作流程

import cProfile as profile
import pstats

pr = profile.Profile()
pr.runcall(myFunc, args, kwargs)

st = pstats.Stats(pr)
st.print_stats() # and other methods like print_callees, print_callers, etc.

这给了我一些关于调用次数等的一般统计数据。 请注意,这是相当神秘的:我在myFunc使用numpy (比如numpy.sum*等),但我无法在stats对象中找到这些调用。 我想看到的是在函数myFunc的源代码的每一行上花费的时间。 我怎么做?

在PyPI - line_profiler上有一个很好的包

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM