@@ -77,6 +77,33 @@ def extract_opcode_stats(stats):
77
77
return opcode_stats
78
78
79
79
80
+ def categorized_counts (opcode_stats ):
81
+ basic = 0
82
+ specialized = 0
83
+ not_specialized = 0
84
+ specialized_instructions = {
85
+ op for op in opcode ._specialized_instructions
86
+ if "__" not in op and "ADAPTIVE" not in op }
87
+ adaptive_instructions = {
88
+ op for op in opcode ._specialized_instructions
89
+ if "ADAPTIVE" in op }
90
+ for i , opcode_stat in enumerate (opcode_stats ):
91
+ if "execution_count" not in opcode_stat :
92
+ continue
93
+ count = opcode_stat ['execution_count' ]
94
+ name = opname [i ]
95
+ if "specializable" in opcode_stat :
96
+ not_specialized += count
97
+ elif name in adaptive_instructions :
98
+ not_specialized += count
99
+ elif name in specialized_instructions :
100
+ miss = opcode_stat .get ("specialization.miss" , 0 )
101
+ not_specialized += miss
102
+ specialized += count - miss
103
+ else :
104
+ basic += count
105
+ return basic , not_specialized , specialized
106
+
80
107
def main ():
81
108
stats = gather_stats ()
82
109
opcode_stats = extract_opcode_stats (stats )
@@ -102,6 +129,11 @@ def main():
102
129
for i , opcode_stat in enumerate (opcode_stats ):
103
130
name = opname [i ]
104
131
print_specialization_stats (name , opcode_stat )
132
+ basic , not_specialized , specialized = categorized_counts (opcode_stats )
133
+ print ("Specialization effectiveness:" )
134
+ print (f" Base instructions { basic } { basic * 100 / total :0.1f} %" )
135
+ print (f" Not specialized { not_specialized } { not_specialized * 100 / total :0.1f} %" )
136
+ print (f" Specialized { specialized } { specialized * 100 / total :0.1f} %" )
105
137
print ("Call stats:" )
106
138
total = 0
107
139
for key , value in stats .items ():
0 commit comments