💾 Archived View for tris.fyi › pydoc › pstats captured on 2023-04-26 at 13:31:25. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Back to module index

Go to module by name

pstats

Class for printing reports on profiled python code.

Classes

Enum


    Generic enumeration.

    Derive from this class to define new enumerations.
    

FunctionProfile

FunctionProfile(ncalls: str, tottime: float, percall_tottime: float, cumtime: float, percall_cumtime: float, file_name: str, line_number: int)

SortKey

An enumeration.
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'>
name = <types.DynamicClassAttribute object at 0x7f75e3bec2e0>
  The name of the Enum member.
value = <types.DynamicClassAttribute object at 0x7f75e3bec2b0>
  The value of the Enum member.

Stats

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).print_callers(5)
    
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)
sort_arg_dict_default = {'calls': (((1, -1),), 'call count'), 'ncalls': (((1, -1),), 'call count'), 'cumtime': (((3, -1),), 'cumulative time'), 'cumulative': (((3, -1),), 'cumulative time'), 'filename': (((4, 1),), 'file name'), 'line': (((5, 1),), 'line number'), 'module': (((4, 1),), 'file name'), 'name': (((6, 1),), 'function name'), 'nfl': (((6, 1), (4, 1), (5, 1)), 'name/file/line'), 'pcalls': (((0, -1),), 'primitive call count'), 'stdname': (((7, 1),), 'standard name'), 'time': (((2, -1),), 'internal time'), 'tottime': (((2, -1),), 'internal time')}

StatsProfile

Class for keeping track of an item in inventory.

TupleComp

This class provides a generic function for comparing any two tuples.
    Each instance records a list of tuple-indices (from most significant
    to least significant), and sort direction (ascending or decending) for
    each tuple-index.  The compare functions can then be used as the function
    argument to the system sort() function when a list of tuples need to be
    sorted in the instances order.
compare(self, left, right)

Functions

add_callers

add_callers(target, source)

  Combine two caller lists in a single list.

add_func_stats

add_func_stats(target, source)

  Add together all the stats for two profile entries.

cmp_to_key

cmp_to_key(...)

  Convert a cmp= function into a key= function.

count_calls

count_calls(callers)

  Sum the caller statistics to get total number of calls received.

dataclass

dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False)

  Returns the same class as was passed in, with dunder methods
      added based on the fields defined in the class.

      Examines PEP 526 __annotations__ to determine fields.

      If init is true, an __init__() method is added to the class. If
      repr is true, a __repr__() method is added. If order is true, rich
      comparison dunder methods are added. If unsafe_hash is true, a
      __hash__() method function is added. If frozen is true, fields may
      not be assigned to after instance creation. If match_args is true,
      the __match_args__ tuple is added. If kw_only is true, then by
      default all fields are keyword-only. If slots is true, an
      __slots__ attribute is added.
    

f8

f8(x)

func_get_function_name

func_get_function_name(func)

func_std_string

func_std_string(func_name)

func_strip_path

func_strip_path(func_name)

Other members

Dict = typing.Dict
  A generic version of dict.

Modules

marshal

os

re

sys

time