I'm having issues interpreting cProfile data. To show you my problem I created this simple script.
The function D calls B and C, which both call A.
Function A clearly takes up 1 sec (+overhead).
If we look at the snakeviz results then you can see that the reporting is a bit weird. I understand that in total 2 sec has been spent by function A, but inside function C, function A has spent only 1 sec, and that's what I am interested in. Does anybody know if there is a setting (or a different viewer) where I do not have this issue?
import time import cProfile def A(): time.sleep(1) def B(): A() def C(): A() def D(): B() C() cProfile.run('D()','profileResults.prf') 
D(), where functionA()is called indirectly 2 times, that's why it is showing 2 seconds. FunctionC()is called only once fromD(). From functionC(), functionA()is also called only once. Therefore functionC()time should be 1 second. If you profile functionC()alone, you will get 1 second everywhere.