@@ -188,6 +188,12 @@ def __exit__(*args):
188
188
print ("</details>" )
189
189
print ()
190
190
191
+ def to_str (x ):
192
+ if isinstance (x , int ):
193
+ return format (x , ",d" )
194
+ else :
195
+ return str (x )
196
+
191
197
def emit_table (header , rows ):
192
198
width = len (header )
193
199
header_line = "|"
@@ -203,8 +209,8 @@ def emit_table(header, rows):
203
209
print (under_line )
204
210
for row in rows :
205
211
if width is not None and len (row ) != width :
206
- raise ValueError ("Wrong number of elements in row '" + str (rows ) + "'" )
207
- print ("|" , " | " .join (str (i ) for i in row ), "|" )
212
+ raise ValueError ("Wrong number of elements in row '" + str (row ) + "'" )
213
+ print ("|" , " | " .join (to_str (i ) for i in row ), "|" )
208
214
print ()
209
215
210
216
def emit_execution_counts (opcode_stats , total ):
@@ -251,6 +257,18 @@ def emit_specialization_overview(opcode_stats, total):
251
257
("Not specialized" , not_specialized , f"{ not_specialized * 100 / total :0.1f} %" ),
252
258
("Specialized" , specialized , f"{ specialized * 100 / total :0.1f} %" ),
253
259
))
260
+ for title , field in (("Deferred" , "specialization.deferred" ), ("Misses" , "specialization.miss" )):
261
+ total = 0
262
+ counts = []
263
+ for i , opcode_stat in enumerate (opcode_stats ):
264
+ value = opcode_stat .get (field , 0 )
265
+ counts .append ((value , opname [i ]))
266
+ total += value
267
+ counts .sort (reverse = True )
268
+ if total :
269
+ with Section (f"{ title } by instruction" , 3 ):
270
+ rows = [ (name , count , f"{ 100 * count / total :0.1f} %" ) for (count , name ) in counts [:10 ] ]
271
+ emit_table (("Name" , "Count:" , "Ratio:" ), rows )
254
272
255
273
def emit_call_stats (stats ):
256
274
stats_path = os .path .join (os .path .dirname (__file__ ), "../../Include/pystats.h" )
0 commit comments