@@ -188,6 +188,12 @@ def __exit__(*args):
188188 print ("</details>" )
189189 print ()
190190
191+ def to_str (x ):
192+ if isinstance (x , int ):
193+ return format (x , ",d" )
194+ else :
195+ return str (x )
196+
191197def emit_table (header , rows ):
192198 width = len (header )
193199 header_line = "|"
@@ -203,8 +209,8 @@ def emit_table(header, rows):
203209 print (under_line )
204210 for row in rows :
205211 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 ), "|" )
208214 print ()
209215
210216def emit_execution_counts (opcode_stats , total ):
@@ -251,6 +257,18 @@ def emit_specialization_overview(opcode_stats, total):
251257 ("Not specialized" , not_specialized , f"{ not_specialized * 100 / total :0.1f} %" ),
252258 ("Specialized" , specialized , f"{ specialized * 100 / total :0.1f} %" ),
253259 ))
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 )
254272
255273def emit_call_stats (stats ):
256274 stats_path = os .path .join (os .path .dirname (__file__ ), "../../Include/pystats.h" )
0 commit comments