Skip to content

Commit d840e72

Browse files
fix the compare summary issue
1 parent e2e034d commit d840e72

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

.github/scripts/op_perf_comparison.py

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,30 @@ def display_comparison(results, threshold, xpu_file, compare_both):
100100
# Classify records based on changes
101101
regression_records = []
102102
improvement_records = []
103+
mixed_records = []
103104

104105
for record in results.to_dict('records'):
105-
has_profile_change = 'profile_change' in record and record['profile_change'] in ('↑', '↓')
106-
has_e2e_change = 'e2e_change' in record and record['e2e_change'] in ('↑', '↓')
106+
profile_change = record.get('profile_change')
107+
e2e_change = record.get('e2e_change')
107108

108-
# If either metric shows regression, count as regression
109-
if (has_profile_change and record['profile_change'] == '↓') or \
110-
(has_e2e_change and record['e2e_change'] == '↓'):
109+
profile_regression = profile_change == '↓'
110+
profile_improve = profile_change == '↑'
111+
e2e_regression = e2e_change == '↓'
112+
e2e_improve = e2e_change == '↑'
113+
114+
if (profile_regression and e2e_improve) or (profile_improve and e2e_regression):
115+
mixed_records.append(record)
116+
elif profile_regression or e2e_regression:
111117
regression_records.append(record)
112-
# If either metric shows improvement, count as improvement
113-
elif (has_profile_change and record['profile_change'] == '↑') or \
114-
(has_e2e_change and record['e2e_change'] == '↑'):
118+
elif profile_improve or e2e_improve:
115119
improvement_records.append(record)
116120

117121
# Print results
118122
if regression_records:
119123
print("\n🔴 Regression:")
120124
regression_display = [r for r in display_records
121-
if r['Case Name'] in [x['case_name'] for x in regression_records]]
125+
if (r.get('Profile Change', '') == '↓' or r.get('E2E Change', '') == '↓')
126+
and not (r.get('Profile Change', '') == '↑' or r.get('E2E Change', '') == '↑')]
122127
print(tabulate(
123128
regression_display,
124129
headers="keys",
@@ -130,7 +135,8 @@ def display_comparison(results, threshold, xpu_file, compare_both):
130135
if improvement_records:
131136
print("\n🟢 Improvement:")
132137
improvement_display = [r for r in display_records
133-
if r['Case Name'] in [x['case_name'] for x in improvement_records]]
138+
if (r.get('Profile Change', '') == '↑' or r.get('E2E Change', '') == '↑')
139+
and not (r.get('Profile Change', '') == '↓' or r.get('E2E Change', '') == '↓')]
134140
print(tabulate(
135141
improvement_display,
136142
headers="keys",
@@ -139,6 +145,19 @@ def display_comparison(results, threshold, xpu_file, compare_both):
139145
floatfmt=".2f"
140146
))
141147

148+
if mixed_records:
149+
print("\n🟡 Mixed Changes (one metric improves, another regression):")
150+
mixed_display = [r for r in display_records
151+
if ((r.get('Profile Change', '') == '↑' and r.get('E2E Change', '') == '↓') or
152+
(r.get('Profile Change', '') == '↓' and r.get('E2E Change', '') == '↑'))]
153+
print(tabulate(
154+
mixed_display,
155+
headers="keys",
156+
tablefmt='grid',
157+
showindex=False,
158+
floatfmt=".2f"
159+
))
160+
142161
# Generate GitHub summary
143162
summary_output = f"## {direction} Performance Comparison Results\n"
144163

@@ -162,6 +181,17 @@ def display_comparison(results, threshold, xpu_file, compare_both):
162181
floatfmt=".2f"
163182
) + "\n"
164183

184+
if mixed_records:
185+
summary_output += "\n### 🟡 Mixed Changes\n"
186+
summary_output += "One metric improves while another regression\n"
187+
summary_output += tabulate(
188+
[r for r in display_records if r['Case Name'] in [x['case_name'] for x in mixed_records]],
189+
headers="keys",
190+
tablefmt='github',
191+
showindex=False,
192+
floatfmt=".2f"
193+
) + "\n"
194+
165195
write_to_github_summary(summary_output)
166196

167197
def compare_time_values(xpu_file, baseline_file, threshold=0.05, profile_only=False, e2e_only=False):

0 commit comments

Comments
 (0)