2011-08-15 24 views
23

biegnę to:Jak odczytać dane wyjściowe polecenia 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--

Co zrobić każdy z tottime, percall, cumtime? ncalls jest dość oczywiste (liczba razy wywoływana jest funkcja). My odgadnąć jest to, że tottime jest całkowity czas spędzony w funkcji wykluczając czas spędzony w ramach własnych wywołań funkcji; percall to ???; cumtime to całkowity czas spędzony w wywołaniu funkcji, w tym czas spędzony w ramach jego własnych wywołań funkcji (ale oczywiście, z wyłączeniem podwójnego liczenia). docs nie są zbyt pomocne; Wyszukiwarka Google też nie pomaga.

Odpowiedz

24

to tylko wygodny wrapper dla własnej profilera Pythona, dla których dokumentacja jest tutaj:

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

Cytując:

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 
Powiązane problemy