2011-08-15 16 views
23

corro esto:¿Cómo leo la salida del comando 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--

Qué hacer cada uno de tottime, percall, cumtime? ncalls es bastante obvio (número de veces que se llama a la función). Mi supongo es que tottime es el tiempo total dedicado a la función, excluyendo el tiempo empleado en sus llamadas a funciones; percall es ???; el tiempo de permanencia es el tiempo total que se pasa en la llamada a la función, incluido el tiempo empleado en sus propias llamadas a función (pero, por supuesto, excluye el doble conteo). docs no son demasiado útiles; La búsqueda de Google tampoco ayuda.

Respuesta

24

Es sólo un envoltorio conveniente para el propio generador de perfiles de Python, la documentación para el que está aquí:

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

Citando:

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), 
percall 
    is the quotient of tottime divided by ncalls 
cumtime 
    is the total time spent in this and all subfunctions (from invocation till exit). This figure is accurate even for recursive functions. 
percall 
    is the quotient of cumtime divided by primitive calls 
Cuestiones relacionadas