如何读取IPython%prun(profiler)命令的输出? [英] How do I read the output of the IPython %prun (profiler) command?

查看:118
本文介绍了如何读取IPython%prun(profiler)命令的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行这个:

In [303]: %prun my_function()
         384707 function calls (378009 primitive calls) in 83.116 CPU seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
    37706   41.693    0.001   41.693    0.001 {max}
    20039   36.000    0.002   36.000    0.002 {min}
    18835    1.848    0.000    2.208    0.000 helper.py:119(fftfreq)

-snip-

tottime,percall和cumtime分别是什么? ncalls很明显(调用函数的次数).我的 guess 是,tottime是在函数中花费的总时间,不包括在其自身函数调用中花费的时间; percall是???; cumtime是在函数调用中花费的总时间,包括在其自身的函数调用中花费的时间(当然,不包括重复计数). 文档不是太有帮助了Google搜索也无济于事.

What do each of tottime, percall, cumtime? ncalls is fairly obviously (number of times the function is called). My guess is that tottime is the total time spent in the function excluding time spent within its own function calls; percall is ???; cumtime is total time spent in the function call including time spent within its own function calls (but of course, excluding double counting). The docs are not too helpful; Google search doesn't help either.

推荐答案

它只是Python自己的探查器的便捷包装,其文档位于:

It's just a convenient wrapper for Python's own profiler, the documentation for which is here:

http://docs.python.org/library/profile.html# module-pstats

报价:

n次通话 通话次数,

ncalls for the number of calls,

总时间(花费在给定功能上的总时间)(不包括调用子功能的时间)

tottime for the total time spent in the given function (and excluding time made in calls to sub-functions),

每次通话次数是tottime除以ncalls的商数

percall is the quotient of tottime divided by ncalls

cumtime 是此功能和所有子功能(从调用到退出)花费的总时间.这个数字是准确的,即使是递归的 功能.

cumtime is the total time spent in this and all subfunctions (from invocation till exit). This figure is accurate even for recursive functions.

每次通话是cumtime除以原始通话的商数

percall is the quotient of cumtime divided by primitive calls

这篇关于如何读取IPython%prun(profiler)命令的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆