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

Function regenerate_expected_output

Lib/test/test_profile.py:138–156  ·  view source on GitHub ↗
(filename, cls)

Source from the content-addressed store, hash-verified

136
137
138def regenerate_expected_output(filename, cls):
139 filename = filename.rstrip('co')
140 print('Regenerating %s...' % filename)
141 results = cls.do_profiling()
142
143 newfile = []
144 with open(filename, 'r') as f:
145 for line in f:
146 newfile.append(line)
147 if line.startswith('#--cut'):
148 break
149
150 with open(filename, 'w') as f:
151 f.writelines(newfile)
152 f.write("_ProfileOutput = {}\n")
153 for i, method in enumerate(cls.methodnames):
154 f.write('_ProfileOutput[%r] = """\\\n%s"""\n' % (
155 method, results[i+1]))
156 f.write('\nif __name__ == "__main__":\n main()\n')
157
158@contextmanager
159def silent():

Callers 2

mainFunction · 0.90
mainFunction · 0.85

Calls 8

enumerateFunction · 0.85
do_profilingMethod · 0.80
openFunction · 0.50
rstripMethod · 0.45
appendMethod · 0.45
startswithMethod · 0.45
writelinesMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…