18
18
# repeat.sh 3 mypatch/bin/Benchmark_Driver run -o -O > mypatch.O.times
19
19
# compare_perf_tests.py tot.O.times mypatch.O.times | sort -t, -n -k 6 | column -s, -t
20
20
21
+ from __future__ import print_function
21
22
import re
22
23
import sys
23
24
25
+
24
26
VERBOSE = 0
25
27
26
28
# #,TEST,SAMPLES,MIN(ms),MAX(ms),MEAN(ms),SD(ms),MEDIAN(ms)
@@ -52,7 +54,7 @@ def get_scores(fname):
52
54
try :
53
55
for line in f :
54
56
if VERBOSE :
55
- print ("Parsing" , line ,)
57
+ print ("Parsing" , line , end = "" )
56
58
m = SCORERE .match (line )
57
59
is_total = False
58
60
if not m :
@@ -85,8 +87,8 @@ def is_max_score(newscore, maxscore, invert):
85
87
86
88
87
89
def compare_scores (key , score1 , worstsample1 , score2 , worstsample2 , runs , num ):
88
- print (num .rjust (3 ),)
89
- print (key .ljust (25 ),)
90
+ print (num .rjust (3 ), end = "" )
91
+ print (key .ljust (25 ), end = "" )
90
92
bestscore1 = None
91
93
bestscore2 = None
92
94
worstscore1 = None
@@ -100,7 +102,7 @@ def compare_scores(key, score1, worstsample1, score2, worstsample2, runs, num):
100
102
if is_max_score (newscore = score , maxscore = worstscore1 , invert = minworst ):
101
103
worstscore1 = score
102
104
if PrintAllScores :
103
- print ("%d" % score ).rjust (16 ),
105
+ print (( "%d" % score ).rjust (16 ), end = "" )
104
106
for score in worstsample1 :
105
107
if is_max_score (newscore = score , maxscore = worstscore1 , invert = minworst ):
106
108
worstscore1 = score
@@ -110,47 +112,47 @@ def compare_scores(key, score1, worstsample1, score2, worstsample2, runs, num):
110
112
if is_max_score (newscore = score , maxscore = worstscore2 , invert = minworst ):
111
113
worstscore2 = score
112
114
if PrintAllScores :
113
- print ("%d" % score ).rjust (16 ),
115
+ print (( "%d" % score ).rjust (16 ), end = "" )
114
116
r += 1
115
117
for score in worstsample2 :
116
118
if is_max_score (newscore = score , maxscore = worstscore2 , invert = minworst ):
117
119
worstscore2 = score
118
120
while r < runs :
119
121
if PrintAllScores :
120
- print ("0" ) .rjust (9 ),
122
+ print ("0" .rjust (9 ), end = "" )
121
123
r += 1
122
124
123
125
if not PrintAllScores :
124
- print ("%d" % bestscore1 ).rjust (16 ),
125
- print ("%d" % bestscore2 ).rjust (16 ),
126
+ print (( "%d" % bestscore1 ).rjust (16 ), end = "" )
127
+ print (( "%d" % bestscore2 ).rjust (16 ), end = "" )
126
128
127
- print ("%+d" % (bestscore2 - bestscore1 )).rjust (9 ),
129
+ print (( "%+d" % (bestscore2 - bestscore1 )).rjust (9 ), end = "" )
128
130
129
131
if bestscore1 != 0 and bestscore2 != 0 :
130
- print ("%+.1f%%" % (((float (bestscore2 ) / bestscore1 ) - 1 ) * 100 )).rjust (9 ),
132
+ print (( "%+.1f%%" % (((float (bestscore2 ) / bestscore1 ) - 1 ) * 100 )).rjust (9 ), end = "" )
131
133
if ShowSpeedup :
132
134
Num , Den = float (bestscore2 ), float (bestscore1 )
133
135
if IsTime :
134
136
Num , Den = Den , Num
135
- print ("%.2fx" % (Num / Den )).rjust (9 ),
137
+ print (( "%.2fx" % (Num / Den )).rjust (9 ), end = "" )
136
138
else :
137
- print ("*" .rjust (9 ),)
139
+ print ("*" .rjust (9 ), end = "" )
138
140
if ShowSpeedup :
139
- print ("*" .rjust (9 ),)
141
+ print ("*" .rjust (9 ), end = "" )
140
142
# check if the worst->best interval for each configuration overlap.
141
143
if minbest :
142
144
if (bestscore1 < bestscore2 and bestscore2 < worstscore1 ) \
143
145
or (bestscore2 < bestscore1 and bestscore1 < worstscore2 ):
144
- print ("(?)" ,)
146
+ print ("(?)" , end = "" )
145
147
else :
146
148
if (worstscore1 < worstscore2 and worstscore2 < bestscore1 ) \
147
149
or (worstscore2 < worstscore1 and worstscore1 < bestscore2 ):
148
- print ("(?)" ,)
150
+ print ("(?)" , end = "" )
149
151
print ()
150
152
151
153
152
154
def print_best_scores (key , scores ):
153
- print (key ,)
155
+ print (key , end = "" )
154
156
bestscore = None
155
157
minbest = IsTime
156
158
for score in scores :
@@ -194,22 +196,22 @@ def usage():
194
196
keys = list (set (scores1 .keys () + scores2 .keys ()))
195
197
keys .sort ()
196
198
if VERBOSE :
197
- print ("comparing " , file1 , "vs" , file2 , "=" ,)
199
+ print ("comparing " , file1 , "vs" , file2 , "=" , end = "" )
198
200
if IsTime :
199
201
print (file1 , "/" , file2 )
200
202
else :
201
203
print (file2 , "/" , file1 )
202
204
203
- print ("#" .rjust (3 ),)
204
- print ("TEST" .ljust (25 ),)
205
+ print ("#" .rjust (3 ), end = "" )
206
+ print ("TEST" .ljust (25 ), end = "" )
205
207
if PrintAllScores :
206
208
for i in range (0 , runs ):
207
- print (("OLD_RUN%d" % i ).rjust (9 ),)
209
+ print (("OLD_RUN%d" % i ).rjust (9 ), end = "" )
208
210
for i in range (0 , runs ):
209
- print (("NEW_RUN%d" % i ).rjust (9 ),)
211
+ print (("NEW_RUN%d" % i ).rjust (9 ), end = "" )
210
212
else :
211
- print ("BEST_OLD_MIN(μs)" .rjust (17 ),)
212
- print ("BEST_NEW_MIN(μs)" .rjust (17 ),)
213
+ print ("BEST_OLD_MIN(μs)" .rjust (17 ), end = "" )
214
+ print ("BEST_NEW_MIN(μs)" .rjust (17 ), end = "" )
213
215
print ('DELTA' .rjust (9 ), '%DELTA' .rjust (9 ), 'SPEEDUP' .rjust (9 ))
214
216
215
217
for key in keys :
0 commit comments