-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
regresion_detect.py
44 lines (33 loc) · 1.09 KB
/
regresion_detect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
import pandas
def sanitize_df(df):
df = df.iloc[:, 1:].drop("run", axis=1)
g_df = df.groupby(["name", "key", "dev"])
mean = g_df.mean().reset_index()
return mean
def join_dfs(df_a, df_b):
df = pandas.merge(df_a, df_b, on=["name", "key", "dev"])
return df
def calc_relative_perf(df):
df["perf"] = df["time_y"] / df["time_x"]
return df
def main():
df_1 = pandas.read_csv(sys.argv[1])
df_2 = pandas.read_csv(sys.argv[2])
mean_1 = sanitize_df(df_1)
mean_2 = sanitize_df(df_2)
comp = join_dfs(mean_1, mean_2)
perf = calc_relative_perf(comp)
print(perf.to_string())
# Remove colunmns with a time less > 1e-4 s
perf = perf[(perf["time_x"] >= 1e-4) & (perf["time_y"] >= 1e-4)]
# Find columns where performance has degraded at least 25%
degrade = perf[perf["perf"] >= 1.25]
if degrade.shape[0] == 0:
print("No perf degradation")
else:
print("Performance degradation detected for")
print(degrade.to_string())
raise RuntimeError("Performance regresion")
if __name__ == '__main__':
main()