Issue #3389: Allow resolving dotted names for handlers in logging configuration files...
[python.git] / Lib / test / test_cprofile.py
blob7ed6cec2299be05519e75206567515a3d189fb0b
1 """Test suite for the cProfile module."""
3 import sys
4 from test.test_support import run_unittest
6 # rip off all interesting stuff from test_profile
7 import cProfile
8 from test.test_profile import ProfileTest, regenerate_expected_output
10 class CProfileTest(ProfileTest):
11 profilerclass = cProfile.Profile
14 def test_main():
15 run_unittest(CProfileTest)
17 def main():
18 if '-r' not in sys.argv:
19 test_main()
20 else:
21 regenerate_expected_output(__file__, CProfileTest)
24 # Don't remove this comment. Everything below it is auto-generated.
25 #--cut--------------------------------------------------------------------------
26 CProfileTest.expected_output['print_stats'] = """\
27 126 function calls (106 primitive calls) in 1.000 CPU seconds
29 Ordered by: standard name
31 ncalls tottime percall cumtime percall filename:lineno(function)
32 1 0.000 0.000 1.000 1.000 <string>:1(<module>)
33 28 0.028 0.001 0.028 0.001 profilee.py:110(__getattr__)
34 1 0.270 0.270 1.000 1.000 profilee.py:25(testfunc)
35 23/3 0.150 0.007 0.170 0.057 profilee.py:35(factorial)
36 20 0.020 0.001 0.020 0.001 profilee.py:48(mul)
37 2 0.040 0.020 0.600 0.300 profilee.py:55(helper)
38 4 0.116 0.029 0.120 0.030 profilee.py:73(helper1)
39 2 0.000 0.000 0.140 0.070 profilee.py:84(helper2_indirect)
40 8 0.312 0.039 0.400 0.050 profilee.py:88(helper2)
41 8 0.064 0.008 0.080 0.010 profilee.py:98(subhelper)
42 12 0.000 0.000 0.012 0.001 {hasattr}
43 4 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}
44 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
45 8 0.000 0.000 0.000 0.000 {range}
46 4 0.000 0.000 0.000 0.000 {sys.exc_info}
49 """
50 CProfileTest.expected_output['print_callers'] = """\
51 Ordered by: standard name
53 Function was called by...
54 ncalls tottime cumtime
55 <string>:1(<module>) <-
56 profilee.py:110(__getattr__) <- 16 0.016 0.016 profilee.py:98(subhelper)
57 12 0.012 0.012 {hasattr}
58 profilee.py:25(testfunc) <- 1 0.270 1.000 <string>:1(<module>)
59 profilee.py:35(factorial) <- 1 0.014 0.130 profilee.py:25(testfunc)
60 20/3 0.130 0.147 profilee.py:35(factorial)
61 2 0.006 0.040 profilee.py:84(helper2_indirect)
62 profilee.py:48(mul) <- 20 0.020 0.020 profilee.py:35(factorial)
63 profilee.py:55(helper) <- 2 0.040 0.600 profilee.py:25(testfunc)
64 profilee.py:73(helper1) <- 4 0.116 0.120 profilee.py:55(helper)
65 profilee.py:84(helper2_indirect) <- 2 0.000 0.140 profilee.py:55(helper)
66 profilee.py:88(helper2) <- 6 0.234 0.300 profilee.py:55(helper)
67 2 0.078 0.100 profilee.py:84(helper2_indirect)
68 profilee.py:98(subhelper) <- 8 0.064 0.080 profilee.py:88(helper2)
69 {hasattr} <- 4 0.000 0.004 profilee.py:73(helper1)
70 8 0.000 0.008 profilee.py:88(helper2)
71 {method 'append' of 'list' objects} <- 4 0.000 0.000 profilee.py:73(helper1)
72 {method 'disable' of '_lsprof.Profiler' objects} <-
73 {range} <- 8 0.000 0.000 profilee.py:98(subhelper)
74 {sys.exc_info} <- 4 0.000 0.000 profilee.py:73(helper1)
77 """
78 CProfileTest.expected_output['print_callees'] = """\
79 Ordered by: standard name
81 Function called...
82 ncalls tottime cumtime
83 <string>:1(<module>) -> 1 0.270 1.000 profilee.py:25(testfunc)
84 profilee.py:110(__getattr__) ->
85 profilee.py:25(testfunc) -> 1 0.014 0.130 profilee.py:35(factorial)
86 2 0.040 0.600 profilee.py:55(helper)
87 profilee.py:35(factorial) -> 20/3 0.130 0.147 profilee.py:35(factorial)
88 20 0.020 0.020 profilee.py:48(mul)
89 profilee.py:48(mul) ->
90 profilee.py:55(helper) -> 4 0.116 0.120 profilee.py:73(helper1)
91 2 0.000 0.140 profilee.py:84(helper2_indirect)
92 6 0.234 0.300 profilee.py:88(helper2)
93 profilee.py:73(helper1) -> 4 0.000 0.004 {hasattr}
94 4 0.000 0.000 {method 'append' of 'list' objects}
95 4 0.000 0.000 {sys.exc_info}
96 profilee.py:84(helper2_indirect) -> 2 0.006 0.040 profilee.py:35(factorial)
97 2 0.078 0.100 profilee.py:88(helper2)
98 profilee.py:88(helper2) -> 8 0.064 0.080 profilee.py:98(subhelper)
99 8 0.000 0.008 {hasattr}
100 profilee.py:98(subhelper) -> 16 0.016 0.016 profilee.py:110(__getattr__)
101 8 0.000 0.000 {range}
102 {hasattr} -> 12 0.012 0.012 profilee.py:110(__getattr__)
103 {method 'append' of 'list' objects} ->
104 {method 'disable' of '_lsprof.Profiler' objects} ->
105 {range} ->
106 {sys.exc_info} ->
111 if __name__ == "__main__":
112 main()