177
177
for entry in self.data:
178
178
totaltime = int(entry.totaltime * 1000)
179
179
max_cost = max(max_cost, totaltime)
180
print >> self.out_file, 'summary: %d' % (max_cost,)
180
self.out_file.write('summary: %d\n' % (max_cost,))
182
182
def _entry(self, entry):
183
183
out_file = self.out_file
184
184
code = entry.code
185
185
inlinetime = int(entry.inlinetime * 1000)
186
#print >> out_file, 'ob=%s' % (code.co_filename,)
187
if isinstance(code, str):
188
print >> out_file, 'fi=~'
190
print >> out_file, 'fi=%s' % (code.co_filename,)
191
print >> out_file, 'fn=%s' % (label(code, True),)
192
if isinstance(code, str):
193
print >> out_file, '0 ', inlinetime
195
print >> out_file, '%d %d' % (code.co_firstlineno, inlinetime)
186
#out_file.write('ob=%s\n' % (code.co_filename,))
187
if isinstance(code, str):
188
out_file.write('fi=~\n')
190
out_file.write('fi=%s\n' % (code.co_filename,))
191
out_file.write('fn=%s\n' % (label(code, True),))
192
if isinstance(code, str):
193
out_file.write('0 ' + inlinetime + '\n')
195
out_file.write('%d %d\n' % (code.co_firstlineno, inlinetime))
196
196
# recursive calls are counted in entry.calls
198
198
calls = entry.calls
204
204
lineno = code.co_firstlineno
205
205
for subentry in calls:
206
206
self._subentry(lineno, subentry)
209
209
def _subentry(self, lineno, subentry):
210
210
out_file = self.out_file
211
211
code = subentry.code
212
212
totaltime = int(subentry.totaltime * 1000)
213
#print >> out_file, 'cob=%s' % (code.co_filename,)
214
print >> out_file, 'cfn=%s' % (label(code, True),)
213
#out_file.write('cob=%s\n' % (code.co_filename,))
214
out_file.write('cfn=%s\n' % (label(code, True),))
215
215
if isinstance(code, str):
216
print >> out_file, 'cfi=~'
217
print >> out_file, 'calls=%d 0' % (subentry.callcount,)
216
out_file.write('cfi=~\n')
217
out_file.write('calls=%d 0\n' % (subentry.callcount,))
219
print >> out_file, 'cfi=%s' % (code.co_filename,)
220
print >> out_file, 'calls=%d %d' % (
221
subentry.callcount, code.co_firstlineno)
222
print >> out_file, '%d %d' % (lineno, totaltime)
219
out_file.write('cfi=%s\n' % (code.co_filename,))
220
out_file.write('calls=%d %d\n' % (
221
subentry.callcount, code.co_firstlineno))
222
out_file.write('%d %d\n' % (lineno, totaltime))
252
252
sys.argv = sys.argv[1:]
254
print >> sys.stderr, "usage: lsprof.py <script> <arguments...>"
254
sys.stderr.write("usage: lsprof.py <script> <arguments...>\n")
256
256
sys.path.insert(0, os.path.abspath(os.path.dirname(sys.argv[0])))
257
257
stats = profile(execfile, sys.argv[0], globals(), locals())