pstats.Stats.print_callers()

print_callers(*restrictions) This method for the Stats class prints a list of all functions that called each function in the profiled database. The ordering is identical to that provided by print_stats(), and the definition of the restricting argument is also identical. Each caller is reported on its own line. The format differs slightly depending on the profiler that produced the stats: With profile, a number is shown in parentheses after each caller to show how many times this specific cal

pstats.Stats.print_callees()

print_callees(*restrictions) This method for the Stats class prints a list of all function that were called by the indicated function. Aside from this reversal of direction of calls (re: called vs was called by), the arguments and ordering are identical to the print_callers() method.

pstats.Stats.dump_stats()

dump_stats(filename) Save the data loaded into the Stats object to a file named filename. The file is created if it does not exist, and is overwritten if it already exists. This is equivalent to the method of the same name on the profile.Profile and cProfile.Profile classes.

pstats.Stats.add()

add(*filenames) This method of the Stats class accumulates additional profiling information into the current profiling object. Its arguments should refer to filenames created by the corresponding version of profile.run() or cProfile.run(). Statistics for identically named (re: file, line, name) functions are automatically accumulated into single function statistics.

pstats.Stats

class pstats.Stats(*filenames or profile, stream=sys.stdout) This class constructor creates an instance of a “statistics object” from a filename (or list of filenames) or from a Profile instance. Output will be printed to the stream specified by stream. The file selected by the above constructor must have been created by the corresponding version of profile or cProfile. To be specific, there is no file compatibility guaranteed with future versions of this profiler, and there is no compatibil

property

class property(fget=None, fset=None, fdel=None, doc=None) Return a property attribute. fget is a function for getting an attribute value. fset is a function for setting an attribute value. fdel is a function for deleting an attribute value. And doc creates a docstring for the attribute. A typical use is to define a managed attribute x: class C: def __init__(self): self._x = None def getx(self): return self._x def setx(self, value): self._x = value d

profile.runctx()

profile.runctx(command, globals, locals, filename=None) This function is similar to run(), with added arguments to supply the globals and locals dictionaries for the command string. This routine executes: exec(command, globals, locals) and gathers profiling statistics as in the run() function above.

profile.run()

profile.run(command, filename=None, sort=-1) This function takes a single argument that can be passed to the exec() function, and an optional file name. In all cases this routine executes: exec(command, __main__.__dict__, __main__.__dict__) and gathers profiling statistics from the execution. If no file name is present, then this function automatically creates a Stats instance and prints a simple profiling report. If the sort value is specified it is passed to this Stats instance to control

profile.Profile.runctx()

runctx(cmd, globals, locals) Profile the cmd via exec() with the specified global and local environment.

profile.Profile.runcall()

runcall(func, *args, **kwargs) Profile func(*args, **kwargs)