Python's profile module: <string>:1(?)

≯℡__Kan透↙ 提交于 2019-12-22 01:25:35

问题


I am using Python's (v2.4) profile module to profile a numpy script, and the following entry appears to account for the bulk of the execution time:

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 256/1    0.000    0.000    7.710    7.710 <string>:1(?)

Unfortunately, its appearance makes it hard to Google.

How do I go about figuring out what this is exactly?

edit The profiler is run from the shell as follows: python -m profile -s cumulative script.py


回答1:


Ignore this line. It is an artifact of how the profiler is implemented. It is not telling you anything useful. Look at the "tottime" value for it: 0.000. "tottime" is the amount of time spent executing "<string>:1(?)" excluding time spent executing children of it. So, no time is spent here. "cumtime" and "percall" are large because they include time spent in children. See http://docs.python.org/library/profile.html#cProfile.run for more details.



来源:https://stackoverflow.com/questions/5964126/pythons-profile-module-string1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!