annotate Lib/test/test_profile.py @ 54294:dba767bc3155 legacy-trunk

remove mention of old ctypes version
author Benjamin Peterson <benjamin@python.org>
date Sat, 23 May 2009 20:59:09 +0000
parents 5c43159f5ad0
children 114354b1e0e5 a253fea85af1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20238
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 """Test suite for the profile module."""
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
3 import os
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
4 import sys
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
5 import pstats
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
6 import unittest
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
7 from StringIO import StringIO
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
8 from test.test_support import run_unittest
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
9
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
10 import profile
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
11 from test.profilee import testfunc, timer
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
12
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
13
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
14 class ProfileTest(unittest.TestCase):
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
15
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
16 profilerclass = profile.Profile
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
17 methodnames = ['print_stats', 'print_callers', 'print_callees']
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
18 expected_output = {}
20238
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
19
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
20 @classmethod
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
21 def do_profiling(cls):
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
22 results = []
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
23 prof = cls.profilerclass(timer, 0.001)
46474
5c43159f5ad0 Some tests did not pass on repeated calls (regrtest -R::)
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 45181
diff changeset
24 start_timer = timer()
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
25 prof.runctx("testfunc()", globals(), locals())
46474
5c43159f5ad0 Some tests did not pass on repeated calls (regrtest -R::)
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 45181
diff changeset
26 results.append(timer() - start_timer)
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
27 for methodname in cls.methodnames:
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
28 s = StringIO()
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
29 stats = pstats.Stats(prof, stream=s)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
30 stats.strip_dirs().sort_stats("stdname")
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
31 getattr(stats, methodname)()
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
32 results.append(s.getvalue())
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
33 return results
20240
5c4261e74478 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 20238
diff changeset
34
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
35 def test_cprofile(self):
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
36 results = self.do_profiling()
46474
5c43159f5ad0 Some tests did not pass on repeated calls (regrtest -R::)
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents: 45181
diff changeset
37 self.assertEqual(results[0], 1000)
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
38 for i, method in enumerate(self.methodnames):
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
39 self.assertEqual(results[i+1], self.expected_output[method],
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
40 "Stats.%s output for %s doesn't fit expectation!" %
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
41 (method, self.profilerclass.__name__))
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
42
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
43
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
44 def regenerate_expected_output(filename, cls):
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
45 filename = filename.rstrip('co')
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
46 print 'Regenerating %s...' % filename
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
47 results = cls.do_profiling()
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
48
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
49 newfile = []
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
50 with open(filename, 'r') as f:
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
51 for line in f:
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
52 newfile.append(line)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
53 if line[:6] == '#--cut':
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
54 break
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
55
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
56 with open(filename, 'w') as f:
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
57 f.writelines(newfile)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
58 for i, method in enumerate(cls.methodnames):
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
59 f.write('%s.expected_output[%r] = """\\\n%s"""\n' % (
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
60 cls.__name__, method, results[i+1]))
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
61 f.write('\nif __name__ == "__main__":\n main()\n')
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
62
36459
3abf33264146 Added the cProfile module.
Armin Rigo <arigo@tunes.org>
parents: 35617
diff changeset
63
3abf33264146 Added the cProfile module.
Armin Rigo <arigo@tunes.org>
parents: 35617
diff changeset
64 def test_main():
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
65 run_unittest(ProfileTest)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
66
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
67 def main():
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
68 if '-r' not in sys.argv:
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
69 test_main()
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
70 else:
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
71 regenerate_expected_output(__file__, ProfileTest)
20238
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
72
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
73
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
74 # Don't remove this comment. Everything below it is auto-generated.
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
75 #--cut--------------------------------------------------------------------------
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
76 ProfileTest.expected_output['print_stats'] = """\
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
77 127 function calls (107 primitive calls) in 999.749 CPU seconds
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
78
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
79 Ordered by: standard name
20238
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
80
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
81 ncalls tottime percall cumtime percall filename:lineno(function)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
82 4 -0.004 -0.001 -0.004 -0.001 :0(append)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
83 4 -0.004 -0.001 -0.004 -0.001 :0(exc_info)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
84 12 -0.024 -0.002 11.964 0.997 :0(hasattr)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
85 8 -0.008 -0.001 -0.008 -0.001 :0(range)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
86 1 0.000 0.000 0.000 0.000 :0(setprofile)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
87 1 -0.002 -0.002 999.751 999.751 <string>:1(<module>)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
88 0 0.000 0.000 profile:0(profiler)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
89 1 -0.002 -0.002 999.749 999.749 profile:0(testfunc())
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
90 28 27.972 0.999 27.972 0.999 profilee.py:110(__getattr__)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
91 1 269.996 269.996 999.753 999.753 profilee.py:25(testfunc)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
92 23/3 149.937 6.519 169.917 56.639 profilee.py:35(factorial)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
93 20 19.980 0.999 19.980 0.999 profilee.py:48(mul)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
94 2 39.986 19.993 599.814 299.907 profilee.py:55(helper)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
95 4 115.984 28.996 119.964 29.991 profilee.py:73(helper1)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
96 2 -0.006 -0.003 139.942 69.971 profilee.py:84(helper2_indirect)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
97 8 311.976 38.997 399.896 49.987 profilee.py:88(helper2)
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
98 8 63.968 7.996 79.944 9.993 profilee.py:98(subhelper)
36459
3abf33264146 Added the cProfile module.
Armin Rigo <arigo@tunes.org>
parents: 35617
diff changeset
99
3abf33264146 Added the cProfile module.
Armin Rigo <arigo@tunes.org>
parents: 35617
diff changeset
100
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
101 """
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
102 ProfileTest.expected_output['print_callers'] = """\
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
103 Ordered by: standard name
20238
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
104
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
105 Function was called by...
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
106 :0(append) <- profilee.py:73(helper1)(4) 119.964
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
107 :0(exc_info) <- profilee.py:73(helper1)(4) 119.964
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
108 :0(hasattr) <- profilee.py:73(helper1)(4) 119.964
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
109 profilee.py:88(helper2)(8) 399.896
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
110 :0(range) <- profilee.py:98(subhelper)(8) 79.944
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
111 :0(setprofile) <- profile:0(testfunc())(1) 999.749
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
112 <string>:1(<module>) <- profile:0(testfunc())(1) 999.749
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
113 profile:0(profiler) <-
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
114 profile:0(testfunc()) <- profile:0(profiler)(1) 0.000
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
115 profilee.py:110(__getattr__) <- :0(hasattr)(12) 11.964
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
116 profilee.py:98(subhelper)(16) 79.944
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
117 profilee.py:25(testfunc) <- <string>:1(<module>)(1) 999.751
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
118 profilee.py:35(factorial) <- profilee.py:25(testfunc)(1) 999.753
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
119 profilee.py:35(factorial)(20) 169.917
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
120 profilee.py:84(helper2_indirect)(2) 139.942
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
121 profilee.py:48(mul) <- profilee.py:35(factorial)(20) 169.917
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
122 profilee.py:55(helper) <- profilee.py:25(testfunc)(2) 999.753
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
123 profilee.py:73(helper1) <- profilee.py:55(helper)(4) 599.814
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
124 profilee.py:84(helper2_indirect) <- profilee.py:55(helper)(2) 599.814
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
125 profilee.py:88(helper2) <- profilee.py:55(helper)(6) 599.814
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
126 profilee.py:84(helper2_indirect)(2) 139.942
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
127 profilee.py:98(subhelper) <- profilee.py:88(helper2)(8) 399.896
20238
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
128
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
129
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
130 """
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
131 ProfileTest.expected_output['print_callees'] = """\
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
132 Ordered by: standard name
36459
3abf33264146 Added the cProfile module.
Armin Rigo <arigo@tunes.org>
parents: 35617
diff changeset
133
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
134 Function called...
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
135 :0(append) ->
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
136 :0(exc_info) ->
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
137 :0(hasattr) -> profilee.py:110(__getattr__)(12) 27.972
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
138 :0(range) ->
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
139 :0(setprofile) ->
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
140 <string>:1(<module>) -> profilee.py:25(testfunc)(1) 999.753
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
141 profile:0(profiler) -> profile:0(testfunc())(1) 999.749
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
142 profile:0(testfunc()) -> :0(setprofile)(1) 0.000
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
143 <string>:1(<module>)(1) 999.751
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
144 profilee.py:110(__getattr__) ->
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
145 profilee.py:25(testfunc) -> profilee.py:35(factorial)(1) 169.917
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
146 profilee.py:55(helper)(2) 599.814
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
147 profilee.py:35(factorial) -> profilee.py:35(factorial)(20) 169.917
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
148 profilee.py:48(mul)(20) 19.980
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
149 profilee.py:48(mul) ->
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
150 profilee.py:55(helper) -> profilee.py:73(helper1)(4) 119.964
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
151 profilee.py:84(helper2_indirect)(2) 139.942
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
152 profilee.py:88(helper2)(6) 399.896
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
153 profilee.py:73(helper1) -> :0(append)(4) -0.004
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
154 :0(exc_info)(4) -0.004
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
155 :0(hasattr)(4) 11.964
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
156 profilee.py:84(helper2_indirect) -> profilee.py:35(factorial)(2) 169.917
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
157 profilee.py:88(helper2)(2) 399.896
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
158 profilee.py:88(helper2) -> :0(hasattr)(8) 11.964
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
159 profilee.py:98(subhelper)(8) 79.944
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
160 profilee.py:98(subhelper) -> :0(range)(8) -0.008
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
161 profilee.py:110(__getattr__)(16) 27.972
20238
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
162
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
163
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
164 """
20238
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
165
e7aca2a302cd Hopefully fix the profiler right. Add a test suite that checks that
Guido van Rossum <guido@python.org>
parents:
diff changeset
166 if __name__ == "__main__":
45181
77b371c6958c * Use the same code to profile for test_profile and test_cprofile.
Georg Brandl <georg@python.org>
parents: 36459
diff changeset
167 main()