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

时间:2021-09-17 00:06:50

I'm using python -m cProfile -s calls myscript.py

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

python -m cProfile -s percall myscript.py does not work.

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

The Python documentation says "Look in the Stats documentation for valid sort values.": http://docs.python.org/library/profile.html#module-cProfile, which I cannot find.

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

1 个解决方案

#1


53  

-s only uses the keys found under sort_stats.

-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)

Here's an example

这是一个例子

python -m cProfile -s tottime myscript.py

#1


53  

-s only uses the keys found under sort_stats.

-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)

Here's an example

这是一个例子

python -m cProfile -s tottime myscript.py