##// END OF EJS Templates
py3: use write() instead of print()...
Gregory Szorc -
r40230:1ae0faa1 default
parent child Browse files
Show More
@@ -10,7 +10,7 b' This software may be used and distribute'
10 of the GNU General Public License, incorporated herein by reference.
10 of the GNU General Public License, incorporated herein by reference.
11 """
11 """
12
12
13 from __future__ import absolute_import, print_function
13 from __future__ import absolute_import
14
14
15 def label(code):
15 def label(code):
16 if isinstance(code, str):
16 if isinstance(code, str):
@@ -27,7 +27,7 b' class KCacheGrind(object):'
27
27
28 def output(self, out_file):
28 def output(self, out_file):
29 self.out_file = out_file
29 self.out_file = out_file
30 print('events: Ticks', file=out_file)
30 out_file.write(b'events: Ticks\n')
31 self._print_summary()
31 self._print_summary()
32 for entry in self.data:
32 for entry in self.data:
33 self._entry(entry)
33 self._entry(entry)
@@ -37,23 +37,24 b' class KCacheGrind(object):'
37 for entry in self.data:
37 for entry in self.data:
38 totaltime = int(entry.totaltime * 1000)
38 totaltime = int(entry.totaltime * 1000)
39 max_cost = max(max_cost, totaltime)
39 max_cost = max(max_cost, totaltime)
40 print('summary: %d' % max_cost, file=self.out_file)
40 self.out_file.write(b'summary: %d\n' % max_cost)
41
41
42 def _entry(self, entry):
42 def _entry(self, entry):
43 out_file = self.out_file
43 out_file = self.out_file
44
44
45 code = entry.code
45 code = entry.code
46 if isinstance(code, str):
46 if isinstance(code, str):
47 print('fi=~', file=out_file)
47 out_file.write(b'fi=~\n')
48 else:
48 else:
49 print('fi=%s' % code.co_filename, file=out_file)
49 out_file.write(b'fi=%s\n' % code.co_filename)
50 print('fn=%s' % label(code), file=out_file)
50
51 out_file.write(b'fn=%s\n' % label(code))
51
52
52 inlinetime = int(entry.inlinetime * 1000)
53 inlinetime = int(entry.inlinetime * 1000)
53 if isinstance(code, str):
54 if isinstance(code, str):
54 print('0 ', inlinetime, file=out_file)
55 out_file.write(b'0 %d\n' % inlinetime)
55 else:
56 else:
56 print('%d %d' % (code.co_firstlineno, inlinetime), file=out_file)
57 out_file.write(b'%d %d\n' % (code.co_firstlineno, inlinetime))
57
58
58 # recursive calls are counted in entry.calls
59 # recursive calls are counted in entry.calls
59 if entry.calls:
60 if entry.calls:
@@ -68,19 +69,20 b' class KCacheGrind(object):'
68
69
69 for subentry in calls:
70 for subentry in calls:
70 self._subentry(lineno, subentry)
71 self._subentry(lineno, subentry)
71 print(file=out_file)
72
73 out_file.write(b'\n')
72
74
73 def _subentry(self, lineno, subentry):
75 def _subentry(self, lineno, subentry):
74 out_file = self.out_file
76 out_file = self.out_file
75 code = subentry.code
77 code = subentry.code
76 print('cfn=%s' % label(code), file=out_file)
78 out_file.write(b'cfn=%s\n' % label(code))
77 if isinstance(code, str):
79 if isinstance(code, str):
78 print('cfi=~', file=out_file)
80 out_file.write(b'cfi=~\n')
79 print('calls=%d 0' % subentry.callcount, file=out_file)
81 out_file.write(b'calls=%d 0\n' % subentry.callcount)
80 else:
82 else:
81 print('cfi=%s' % code.co_filename, file=out_file)
83 out_file.write(b'cfi=%s\n' % code.co_filename)
82 print('calls=%d %d' % (
84 out_file.write(b'calls=%d %d\n' % (
83 subentry.callcount, code.co_firstlineno), file=out_file)
85 subentry.callcount, code.co_firstlineno))
84
86
85 totaltime = int(subentry.totaltime * 1000)
87 totaltime = int(subentry.totaltime * 1000)
86 print('%d %d' % (lineno, totaltime), file=out_file)
88 out_file.write(b'%d %d\n' % (lineno, totaltime))
General Comments 0
You need to be logged in to leave comments. Login now