0

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.

Just Me
  • 413
  • 3
  • 9
  • possible duplicate https://stackoverflow.com/questions/40404007/what-is-the-difference-between-tottime-and-cumtime-on-cprofile-output – imM4TT May 24 '23 at 12:16
  • @imM4TT there are many places that discuss how the cumtime can be more than the tottime. Here the question is how can the opposite happen, and I haven't seen this discussed anywhere. – Just Me May 26 '23 at 09:57

0 Answers0