How come the tottime is *greater* than cumtime, when using cProfile?

154 Views Asked by At

I'm using cprofile and snakeviz to analyze some python code. I'm getting weird results like this: profiling results

Two questions:

  1. Given that the cumtime is supposed to include the runtime of the routine and all subroutines, and the tottime is only the runtime of the routine itself - we would expect that the cumtime will always be greater (and this is indeed the most common thing) - why is it different here? Is it related to the fact I'm heavily relying on numpy?

  2. what does the fractional ncalls mean? does it explain the odd cumtime vs. tottime behavior?

EDIT: According to the snakeviz documentation, when there are two numbers in the ncalls column that means the call is recursive. So perhaps the tottime includes only the time spent in the function not including calls to itself recursively, and the cumtime only consider primitive calls. But this is only a guess, will appreciate if someone can make a more definitive statement.

0

There are 0 best solutions below