python - 分析 Python 脚本时按 percall 对 cProfile 输出进行排序

标签 python profiling cprofile

我正在使用 python -m cProfile -s 调用 myscript.py

python -m cProfile -s percall myscript.py 不起作用。

Python 文档说“在 Stats 文档中查找有效的排序值。”:http://docs.python.org/library/profile.html#module-cProfile ,我找不到。

最佳答案

-s 仅使用 the keys found under sort_stats.

calls (call count)
cumulative (cumulative time)
cumtime (cumulative time)
file (file name)
filename (file name)
module (file name)
ncalls (call count)
pcalls (primitive call count)
line (line number)
name (function name)
nfl (name/file/line)
stdname (standard name)
time (internal time)
tottime (internal time)

这是一个例子

python -m cProfile -s tottime myscript.py

关于python - 分析 Python 脚本时按 percall 对 cProfile 输出进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10326936/

相关文章:

python - Snakeviz 只显示一个功能

python - 如何直接传递json对象以从python在rasa nlu中进行训练

python - numpy中一维数组的乘法

python - 如何使用 Beautiful Soup 以正确的顺序提取数据

visual-studio - 如何衡量开发人员构建时间

linux - 如何准确衡量性能,排除后台程序干扰?

python - celery 过期 - 引发异常

x86 - IARG_EXPLICIT_MEMORY_EA 应该用于什么用途?

python - cProfile 未运行

python - 如何使用 cProfile 模块对 python 中的每个函数进行计时?