# pstats - pydoc - phpman

Help on module pstats:

## NAME
    pstats - Class for printing reports on profiled python code.

## MODULE REFERENCE
    <https://docs.python.org/3.10/library/pstats.html>

    The following documentation is automatically generated from the Python
    source files.  It may be incomplete, incorrect or include features that
    are considered implementation detail and may vary between Python
    implementations.  When in doubt, consult the module reference at the
    location listed above.

## CLASSES
    builtins.object
        FunctionProfile
        Stats
        StatsProfile
    builtins.str(builtins.object)
        SortKey(builtins.str, enum.Enum)
    enum.Enum(builtins.object)
        SortKey(builtins.str, enum.Enum)

### class FunctionProfile
     |  FunctionProfile(ncalls: str, tottime: float, percall_tottime: float, cumtime: float, percall_cumtime: float, file_name: str, line_number: int) -> None
     |
     |  FunctionProfile(ncalls: str, tottime: float, percall_tottime: float, cumtime: float, percall_cumtime: float, file_name: str, line_number: int)
     |
     |  Methods defined here:
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __init__(self, ncalls: str, tottime: float, percall_tottime: float, cumtime: float, percall_cumtime: float, file_name: str, line_number: int) -> None
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  __annotations__ = {'cumtime': <class 'float'>, 'file_name': <class 'st...
     |
     |  __dataclass_fields__ = {'cumtime': Field(name='cumtime',type=<class 'f...
     |
     |  __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,or...
     |
     |  __match_args__ = ('ncalls', 'tottime', 'percall_tottime', 'cumtime', '...

### class SortKey
     |  SortKey(value, names=None, *, module=None, qualname=None, type=None, start=1)
     |
     |  An enumeration.
     |
     |  Method resolution order:
     |      SortKey
     |      builtins.str
     |      enum.Enum
     |      builtins.object
     |
     |  Data and other attributes defined here:
     |
     |  CALLS = <SortKey.CALLS: 'calls'>
     |
     |  CUMULATIVE = <SortKey.CUMULATIVE: 'cumulative'>
     |
     |  FILENAME = <SortKey.FILENAME: 'filename'>
     |
     |  LINE = <SortKey.LINE: 'line'>
     |
     |  NAME = <SortKey.NAME: 'name'>
     |
     |  NFL = <SortKey.NFL: 'nfl'>
     |
     |  PCALLS = <SortKey.PCALLS: 'pcalls'>
     |
     |  STDNAME = <SortKey.STDNAME: 'stdname'>
     |
     |  TIME = <SortKey.TIME: 'time'>
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from enum.Enum:
     |
     |  name
     |      The name of the Enum member.
     |
     |  value
     |      The value of the Enum member.
     |
     |  ----------------------------------------------------------------------
     |  Readonly properties inherited from enum.EnumMeta:
     |
     |  __members__
     |      Returns a mapping of member name->value.
     |
     |      This mapping lists all enum members, including aliases. Note that this
     |      is a read-only view of the internal mapping.

### class Stats
     |  Stats(*args, stream=None)
     |
     |  This class is used for creating reports from data generated by the
     |  Profile class.  It is a "friend" of that class, and imports data either
     |  by direct access to members of Profile class, or by reading in a dictionary
     |  that was emitted (via marshal) from the Profile class.
     |
     |  The big change from the previous Profiler (in terms of raw functionality)
     |  is that an "add()" method has been provided to combine Stats from
     |  several distinct profile runs.  Both the constructor and the add()
     |  method now take arbitrarily many file names as arguments.
     |
     |  All the print methods now take an argument that indicates how many lines
     |  to print.  If the arg is a floating point number between 0 and 1.0, then
     |  it is taken as a decimal percentage of the available lines to be printed
     |  (e.g., .1 means print 10% of all available lines).  If it is an integer,
     |  it is taken to mean the number of lines of data that you wish to have
     |  printed.
     |
     |  The sort_stats() method now processes some additional options (i.e., in
     |  addition to the old -1, 0, 1, or 2 that are respectively interpreted as
     |  'stdname', 'calls', 'time', and 'cumulative').  It takes either an
     |  arbitrary number of quoted strings or SortKey enum to select the sort
     |  order.
     |
     |  For example sort_stats('time', 'name') or sort_stats(SortKey.TIME,
     |  SortKey.NAME) sorts on the major key of 'internal function time', and on
     |  the minor key of 'the name of the function'.  Look at the two tables in
     |  sort_stats() and get_sort_arg_defs(self) for more examples.
     |
     |  All methods return self, so you can string together commands like:
     |      Stats('foo', 'goo').strip_dirs().sort_stats('calls').                            [print_stats(5)](https://www.chedong.com/phpMan.php/man/printstats/5/markdown)[.print_callers(5)](https://www.chedong.com/phpMan.php/man/.printcallers/5/markdown)
     |
     |  Methods defined here:
     |
     |  __init__(self, *args, stream=None)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  add(self, *arg_list)
     |
     |  calc_callees(self)
     |
     |  dump_stats(self, filename)
     |      Write the profile data to a file we know how to load back.
     |
     |  eval_print_amount(self, sel, list, msg)
     |
     |  get_print_list(self, sel_list)
     |
     |  get_sort_arg_defs(self)
     |      Expand all abbreviations that are unique.
     |
     |  get_stats_profile(self)
     |      This method returns an instance of StatsProfile, which contains a mapping
     |      of function names to instances of FunctionProfile. Each FunctionProfile
     |      instance holds information related to the function's profile such as how
     |      long the function took to run, how many times it was called, etc...
     |
     |  get_top_level_stats(self)
     |
     |  init(self, arg)
     |
     |  load_stats(self, arg)
     |
     |  print_call_heading(self, name_size, column_title)
     |
     |  print_call_line(self, name_size, source, call_dict, arrow='->')
     |
     |  print_callees(self, *amount)
     |
     |  print_callers(self, *amount)
     |
     |  print_line(self, func)
     |
     |  print_stats(self, *amount)
     |
     |  print_title(self)
     |
     |  reverse_order(self)
     |
     |  sort_stats(self, *field)
     |
     |  strip_dirs(self)
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  sort_arg_dict_default = {'calls': (((1, -1),), 'call count'), 'cumtime...

### class StatsProfile
     |  StatsProfile(total_tt: float, func_profiles: Dict[str, pstats.FunctionProfile]) -> None
     |
     |  Class for keeping track of an item in inventory.
     |
     |  Methods defined here:
     |
     |  __eq__(self, other)
     |      Return self==value.
     |
     |  __hash__(self)
     |      Return hash(self).
     |
     |  __init__(self, total_tt: float, func_profiles: Dict[str, pstats.FunctionProfile]) -> None
     |      Initialize self.  See help(type(self)) for accurate signature.
     |
     |  __repr__(self)
     |      Return repr(self).
     |
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |
     |  __dict__
     |      dictionary for instance variables (if defined)
     |
     |  __weakref__
     |      list of weak references to the object (if defined)
     |
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |
     |  __annotations__ = {'func_profiles': typing.Dict[str, pstats.FunctionPr...
     |
     |  __dataclass_fields__ = {'func_profiles': Field(name='func_profiles',ty...
     |
     |  __dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,or...
     |
     |  __match_args__ = ('total_tt', 'func_profiles')

## DATA
    __all__ = ['Stats', 'SortKey', 'FunctionProfile', 'StatsProfile']

## FILE
    /usr/lib/python3.10/pstats.py


