在分析Python脚本时,通过percall对cProfile输出进行排序

时间:2012-04-26 03:45:33

标签: python profiling cprofile

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

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

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

1 个答案:

答案 0 :(得分:75)

-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