Back to index

python3.2  3.2.2
Classes | Functions | Variables
pstats Namespace Reference

Classes

class  Stats
class  TupleComp
class  ProfileBrowser

Functions

def func_strip_path
def func_get_function_name
def func_std_string
def add_func_stats
def add_callers
def count_calls
def f8

Variables

list __all__ = ["Stats"]
list initprofile = sys.argv[1]
tuple browser = ProfileBrowser(initprofile)

Detailed Description

Class for printing reports on profiled python code.

Function Documentation

def pstats.add_callers (   target,
  source 
)
Combine two caller lists in a single list.

Definition at line 491 of file pstats.py.

00491 
00492 def add_callers(target, source):
00493     """Combine two caller lists in a single list."""
00494     new_callers = {}
00495     for func, caller in target.items():
00496         new_callers[func] = caller
00497     for func, caller in source.items():
00498         if func in new_callers:
00499             if isinstance(caller, tuple):
00500                 # format used by cProfile
00501                 new_callers[func] = tuple([i[0] + i[1] for i in
00502                                            zip(caller, new_callers[func])])
00503             else:
00504                 # format used by profile
00505                 new_callers[func] += caller
00506         else:
00507             new_callers[func] = caller
00508     return new_callers

Here is the caller graph for this function:

def pstats.add_func_stats (   target,
  source 
)
Add together all the stats for two profile entries.

Definition at line 484 of file pstats.py.

00484 
00485 def add_func_stats(target, source):
00486     """Add together all the stats for two profile entries."""
00487     cc, nc, tt, ct, callers = source
00488     t_cc, t_nc, t_tt, t_ct, t_callers = target
00489     return (cc+t_cc, nc+t_nc, tt+t_tt, ct+t_ct,
00490               add_callers(t_callers, callers))

Here is the call graph for this function:

Here is the caller graph for this function:

def pstats.count_calls (   callers)
Sum the caller statistics to get total number of calls received.

Definition at line 509 of file pstats.py.

00509 
00510 def count_calls(callers):
00511     """Sum the caller statistics to get total number of calls received."""
00512     nc = 0
00513     for calls in callers.values():
00514         nc += calls
00515     return nc
00516 
00517 #**************************************************************************
00518 # The following functions support printing of reports
00519 #**************************************************************************

def pstats.f8 (   x)

Definition at line 520 of file pstats.py.

00520 
00521 def f8(x):
00522     return "%8.3f" % x
00523 
00524 #**************************************************************************
00525 # Statistics browser added by ESR, April 2001
00526 #**************************************************************************

Here is the caller graph for this function:

Definition at line 464 of file pstats.py.

00464 
00465 def func_get_function_name(func):
00466     return func[2]

Here is the caller graph for this function:

def pstats.func_std_string (   func_name)

Definition at line 467 of file pstats.py.

00467 
00468 def func_std_string(func_name): # match what old profile produced
00469     if func_name[:2] == ('~', 0):
00470         # special case for built-in functions
00471         name = func_name[2]
00472         if name.startswith('<') and name.endswith('>'):
00473             return '{%s}' % name[1:-1]
00474         else:
00475             return name
00476     else:
00477         return "%s:%d(%s)" % func_name
00478 
00479 #**************************************************************************
00480 # The following functions combine statists for pairs functions.
00481 # The bulk of the processing involves correctly handling "call" lists,
00482 # such as callers and callees.
00483 #**************************************************************************

Here is the caller graph for this function:

def pstats.func_strip_path (   func_name)

Definition at line 460 of file pstats.py.

00460 
00461 def func_strip_path(func_name):
00462     filename, line, name = func_name
00463     return os.path.basename(filename), line, name

Here is the caller graph for this function:


Variable Documentation

list pstats.__all__ = ["Stats"]

Definition at line 30 of file pstats.py.

Definition at line 683 of file pstats.py.

Definition at line 679 of file pstats.py.