Python profiling. What are the columns in runnakerun output?

This may be really obvious, but I just wanted to make sure that I understand that the columns are in runnakerun.

Name, Calls, RCalls, Local, / Call, Cum, / Call, File, Line, Directory

Here are some that I think I understand.

Name - the name of the called function

  • Challenges - the number of calls?
  • File - the file in which the function is stored
  • Line - the line in the file where the function is defined
  • Directory - directory of the function definition file

Those to whom I do not feel comfortable think about the rest:

  • RCalls
  • Local
  • / Call
  • Sperm
  • / Call

thanks

+8
python profiling
source share
2 answers

The best example to illustrate is an example: suppose you have the following program (saved in profileme.py but broken into parts for clarity):

def topfunction(): tinyfunction() for i in range(100000): manytinyfunction() 

The calls are simple - how many times this function was called directly. Of course, when you select items on the left side, these numbers will change, reflecting the number of times the function was called by the selected function. manytinyfunction will be called 100,000 times, so the calls will be 100,000. tinyfunction will be called once, so its calls will be 1.

  for i in range(10): recursive(100) 

rcalls is similar, but also includes calls that occurred during a call. A notification for recursive that only calls 10, but rcalls is 1010 (the definition below, but it calls itself n times if its argument is n.

  alllocal() allcumulative() 

Similarly, local includes all the time spent in the function itself, not counting calls to other functions. Here, alllocal is of great importance here, but allcumulative is nothing here, since it works on a subfunction .

 def tinyfunction(): pass def manytinyfunction(): pass 

/ A call near the local one simply breaks the local value above each call, so manytinyfunction has a bit of time in general, but a very small number in the local / call, since each call is really cheap.

 def alllocal(): for i in range(1000): for j in range(1000): for k in range(1000): pass 

For alllocal / call it will be huge for both local and cumulative, as this function is so expensive and all costs are local.

 def allcumulative(): for i in range(1000): subfunction() def subfunction(): for j in range(1000): for k in range(1000): pass 

/ The call next to the cumulative one is the same as / call for the local one, except that, like the cumulative one, it has the full cost of all calls from the included function. Thus, the local / call number was small for allcumulative , but large for alllocal . Not so for cumulative / calls that will be the same in both cases.

 def recursive(n): if n > 0: return recursive(n-1) else: return 0 

A definition for recursive provided for completeness.

 if __name__=="__main__": topfunction() 

After profiling and running runnake:

 python -m cProfile -o profileme.out profileme.py runsnake profileme.out 

So, note that alllocal is of great importance for both local and cumulative, where allcumulative very different. Note that recursive in both columns is the same - calls to yourself are counted.

The Callees button at the bottom allows you to determine what other functions the called function calls, and Callers allows you to determine who calls the selected function. p>

+5
source share

Here is my understanding:

  • RCalls number of recursive calls
  • Local Total time spent locally executing (without calling another method)
  • /Call Local time for a call
  • Cum Total Total Time
  • /Call Cumulative time per call
+6
source share

All Articles