MCPcopy Index your code
hub / github.com/python/cpython / do_profiling

Method do_profiling

Lib/test/test_profile.py:35–53  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

33
34 @classmethod
35 def do_profiling(cls):
36 results = []
37 prof = cls.profilerclass(timer, 0.001)
38 start_timer = timer()
39 prof.runctx("testfunc()", globals(), locals())
40 results.append(timer() - start_timer)
41 for methodname in cls.methodnames:
42 s = StringIO()
43 stats = pstats.Stats(prof, stream=s)
44 stats.strip_dirs().sort_stats("stdname")
45 getattr(stats, methodname)()
46 output = s.getvalue().splitlines()
47 mod_name = testfunc.__module__.rsplit('.', 1)[1]
48 # Only compare against stats originating from the test file.
49 # Prevents outside code (e.g., the io module) from causing
50 # unexpected output.
51 output = [line.rstrip() for line in output if mod_name in line]
52 results.append('\n'.join(output))
53 return results
54
55 def test_cprofile(self):
56 results = self.do_profiling()

Callers 2

test_cprofileMethod · 0.95

Calls 11

strip_dirsMethod · 0.95
getvalueMethod · 0.95
timerFunction · 0.90
StringIOClass · 0.90
sort_statsMethod · 0.80
runctxMethod · 0.45
appendMethod · 0.45
splitlinesMethod · 0.45
rsplitMethod · 0.45
rstripMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected