Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.profilee Namespace Reference

Classes

class  C

Functions

def timer
def testfunc
def factorial
def mul
def helper
def helper1
def helper2_indirect
def helper2
def subhelper

Variables

int TICKS = 42000

Detailed Description

Input for test_profile.py and test_cprofile.py.

IMPORTANT: This stuff is touchy. If you modify anything above the
test class you'll have to regenerate the stats by running the two
test files.

*ALL* NUMBERS in the expected output are relevant.  If you change
the formatting of pstats, please don't just regenerate the expected
output without checking very carefully that not a single number has
changed.

Function Documentation

Definition at line 35 of file profilee.py.

00035 
00036 def factorial(n):
00037     # 23 calls total
00038     # 170 ticks total, 150 ticks local
00039     # 3 primitive calls, 130, 20 and 20 ticks total
00040     # including 116, 17, 17 ticks local
00041     global TICKS
00042     if n > 0:
00043         TICKS += n
00044         return mul(n, factorial(n-1))
00045     else:
00046         TICKS += 11
00047         return 1

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 55 of file profilee.py.

00055 
00056 def helper():
00057     # 2 calls
00058     # 300 ticks total: 20 ticks local, 260 ticks in subfunctions
00059     global TICKS
00060     TICKS += 1
00061     helper1()                           # 30
00062     TICKS += 2
00063     helper1()                           # 30
00064     TICKS += 6
00065     helper2()                           # 50
00066     TICKS += 3
00067     helper2()                           # 50
00068     TICKS += 2
00069     helper2()                           # 50
00070     TICKS += 5
00071     helper2_indirect()                  # 70
00072     TICKS += 1

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 73 of file profilee.py.

00073 
00074 def helper1():
00075     # 4 calls
00076     # 30 ticks total: 29 ticks local, 1 tick in subfunctions
00077     global TICKS
00078     TICKS += 10
00079     hasattr(C(), "foo")                 # 1
00080     TICKS += 19
00081     lst = []
00082     lst.append(42)                      # 0
00083     sys.exc_info()                      # 0

Here is the caller graph for this function:

Definition at line 88 of file profilee.py.

00088 
00089 def helper2():
00090     # 8 calls
00091     # 50 ticks local: 39 ticks local, 11 ticks in subfunctions
00092     global TICKS
00093     TICKS += 11
00094     hasattr(C(), "bar")                 # 1
00095     TICKS += 13
00096     subhelper()                         # 10
00097     TICKS += 15

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 84 of file profilee.py.

00084 
00085 def helper2_indirect():
00086     helper2()                           # 50
00087     factorial(3)                        # 20

Here is the call graph for this function:

Here is the caller graph for this function:

def test.profilee.mul (   a,
  b 
)

Definition at line 48 of file profilee.py.

00048 
00049 def mul(a, b):
00050     # 20 calls
00051     # 1 tick, local
00052     global TICKS
00053     TICKS += 1
00054     return a * b

Here is the caller graph for this function:

Definition at line 98 of file profilee.py.

00098 
00099 def subhelper():
00100     # 8 calls
00101     # 10 ticks total: 8 ticks local, 2 ticks in subfunctions
00102     global TICKS
00103     TICKS += 2
00104     for i in range(2):                  # 0
00105         try:
00106             C().foo                     # 1 x 2
00107         except AttributeError:
00108             TICKS += 3                  # 3 x 2

Here is the caller graph for this function:

Definition at line 25 of file profilee.py.

00025 
00026 def testfunc():
00027     # 1 call
00028     # 1000 ticks total: 270 ticks local, 730 ticks in subfunctions
00029     global TICKS
00030     TICKS += 99
00031     helper()                            # 300
00032     helper()                            # 300
00033     TICKS += 171
00034     factorial(14)                       # 130

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 22 of file profilee.py.

00022 
00023 def timer():
00024     return TICKS

Here is the caller graph for this function:


Variable Documentation

Definition at line 20 of file profilee.py.