3
3
# Jp Calderone & Itamar Shtull-Trauring
4
4
# Johan Dahlin
5
5
6
+ from __future__ import print_function
6
7
import optparse
7
8
import os
8
9
import sys
@@ -27,7 +28,7 @@ def __init__(self, profiler):
27
28
28
29
def output (self , out_file ):
29
30
self .out_file = out_file
30
- print >> out_file , 'events: Ticks'
31
+ print ( 'events: Ticks' , file = out_file )
31
32
self ._print_summary ()
32
33
for entry in self .data :
33
34
self ._entry (entry )
@@ -37,24 +38,24 @@ def _print_summary(self):
37
38
for entry in self .data :
38
39
totaltime = int (entry .totaltime * 1000 )
39
40
max_cost = max (max_cost , totaltime )
40
- print >> self . out_file , 'summary: %d' % (max_cost ,)
41
+ print ( 'summary: %d' % (max_cost ,), file = self . out_file )
41
42
42
43
def _entry (self , entry ):
43
44
out_file = self .out_file
44
45
45
46
code = entry .code
46
47
#print >> out_file, 'ob=%s' % (code.co_filename,)
47
48
if isinstance (code , str ):
48
- print >> out_file , 'fi=~'
49
+ print ( 'fi=~' , file = out_file )
49
50
else :
50
- print >> out_file , 'fi=%s' % (code .co_filename ,)
51
- print >> out_file , 'fn=%s' % (label (code ),)
51
+ print ( 'fi=%s' % (code .co_filename ,), file = out_file )
52
+ print ( 'fn=%s' % (label (code ),), file = out_file )
52
53
53
54
inlinetime = int (entry .inlinetime * 1000 )
54
55
if isinstance (code , str ):
55
- print >> out_file , '0 ' , inlinetime
56
+ print ( '0 ' , inlinetime , file = out_file )
56
57
else :
57
- print >> out_file , '%d %d' % (code .co_firstlineno , inlinetime )
58
+ print ( '%d %d' % (code .co_firstlineno , inlinetime ), file = out_file )
58
59
59
60
# recursive calls are counted in entry.calls
60
61
if entry .calls :
@@ -69,23 +70,23 @@ def _entry(self, entry):
69
70
70
71
for subentry in calls :
71
72
self ._subentry (lineno , subentry )
72
- print >> out_file
73
+ print ( file = out_file )
73
74
74
75
def _subentry (self , lineno , subentry ):
75
76
out_file = self .out_file
76
77
code = subentry .code
77
78
#print >> out_file, 'cob=%s' % (code.co_filename,)
78
- print >> out_file , 'cfn=%s' % (label (code ),)
79
+ print ( 'cfn=%s' % (label (code ),), file = out_file )
79
80
if isinstance (code , str ):
80
- print >> out_file , 'cfi=~'
81
- print >> out_file , 'calls=%d 0' % (subentry .callcount ,)
81
+ print ( 'cfi=~' , file = out_file )
82
+ print ( 'calls=%d 0' % (subentry .callcount ,), file = out_file )
82
83
else :
83
- print >> out_file , 'cfi=%s' % (code .co_filename ,)
84
- print >> out_file , 'calls=%d %d' % (
85
- subentry .callcount , code .co_firstlineno )
84
+ print ( 'cfi=%s' % (code .co_filename ,), file = out_file )
85
+ print ( 'calls=%d %d' % (
86
+ subentry .callcount , code .co_firstlineno ), file = out_file )
86
87
87
88
totaltime = int (subentry .totaltime * 1000 )
88
- print >> out_file , '%d %d' % (lineno , totaltime )
89
+ print ( '%d %d' % (lineno , totaltime ), file = out_file )
89
90
90
91
def main (args ):
91
92
usage = "%s [-o output_file_path] scriptfile [arg] ..."
0 commit comments