[Python] What is the format of python pstats file?

Discussão em 'Python' iniciado por Stack, Novembro 26, 2024.

  1. Stack

    Stack Membro Participativo

    What is the format of python pstats or lstat file? This is my understanding:

    The pstats file is marshalled dictionary object, with tuple of (filename, lineno, funcname) as keys and a tuple of (nc, cc, tt, ct, callers) elements as values. The values represent:

    • (filename, lineno, funcname) - the function funcname is located in filename:lineno.
    • nc - the number of calls to funcname
    • cc - I have no idea, it is non-recursive or only recursive or primitive or non-primitive calls to funcname? which one is it?
    • tt - this is the total time spent in the function excluding the time spent in subfunctions. What if that subfunction is recursive? Is it uncluded or not?
    • ct - the total time spent in this function
    • callers - the definition is recursive - callers is a dictionary of (filename, lineno, funcname) keys with (nc, cc, tt, ct, callers) as dictionary values.

    When a function is recursive, is each entry of the function added separately to the next level of callers and it nest recursively, or does only the "upper level" invokation keep all the recursively calls statistica accumulated?

    I have read the following links for research:


    Continue reading...

Compartilhe esta Página