87

我在用着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,我找不到。

4

1 回答 1

120

-s 仅使用在 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
于 2012-12-18T00:40:00.587 回答