Skip to content

Commit 839649b

Browse files
committed
Add comparison
1 parent 6f66a26 commit 839649b

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

.github/workflows/test_times.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
types:
88
- completed
99
env:
10-
DIFF_THRESHOLD: 0.10
10+
DIFF_THRESHOLD_REL: 0.10 # Fail if test time increases by more than this ratio
11+
DIFF_THRESHOLD_MS: 3 # Only check tests which take more than this time
1112

1213
jobs:
1314
build-on-mac:

test/compare_elapsed_time.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,34 @@ def get_feature_branch():
124124

125125

126126
def compare_time_elapsed(new_test_df, base_test_df, default_branch):
127+
diff_rel = os.getenv("DIFF_THRESHOLD_REL")
128+
diff_threshold = os.getenv("DIFF_THRESHOLD_MS")
127129
feature_branch = get_feature_branch()
128130
compare_df = new_test_df.merge(base_test_df, how='outer', suffixes=[f" {feature_branch}", f" {default_branch}"], on=['Test Group', 'Test Name'])
129-
print(compare_df)
131+
132+
feat_col = f"Test Times [ms] {feature_branch}"
133+
def_col = f"Test Times [ms] {default_branch}"
134+
compare_df = compare_df[(compare_df[feat_col] > diff_threshold) & (compare_df[def_col] > diff_threshold)]
135+
136+
compare_df.loc[:, "Diff [ms]"] = compare_df[feat_col] - compare_df[def_col]
137+
compare_df = compare_df[compare_df["Diff [ms]"] != 0]
138+
139+
if len(compare_df) == 0:
140+
return True
141+
142+
compare_df.loc[compare_df[def_col] == 0, "Diff Norm"] = 0
143+
compare_df.loc[compare_df[def_col] != 0, "Diff Norm"] = (compare_df[feat_col] - compare_df[def_col]) / compare_df[def_col]
144+
145+
compare_df = compare_df[compare_df["Diff Norm"] >= diff_rel]
146+
147+
print(compare_df.describe())
130148
compare_df.to_csv(Path(__file__).parent / "compare_times.csv", index=False)
131149

150+
if len(compare_df) > 0:
151+
return False
152+
else:
153+
return True
154+
132155

133156
if __name__ == "__main__":
134157

0 commit comments

Comments
 (0)