@@ -41,8 +41,38 @@ def compare_command_logic(args, project_name, project_version):
4141 deployment_type = args .deployment_type
4242 from_ts_ms = args .from_timestamp
4343 to_ts_ms = args .to_timestamp
44+ use_tag = False
45+ use_branch = False
4446 baseline_branch = args .baseline_branch
4547 comparison_branch = args .comparison_branch
48+ by_str = ""
49+ baseline_str = ""
50+ comparison_str = ""
51+ if baseline_branch is not None and comparison_branch is not None :
52+ use_branch = True
53+ by_str = "branch"
54+ baseline_str = baseline_branch
55+ comparison_str = comparison_branch
56+ baseline_tag = args .baseline_tag
57+ comparison_tag = args .comparison_tag
58+ if baseline_tag is not None and comparison_tag is not None :
59+ use_tag = True
60+ by_str = "version"
61+ baseline_str = baseline_tag
62+ comparison_str = comparison_tag
63+ if use_branch is False and use_tag is False :
64+ logging .error (
65+ "You need to provider either "
66+ + "( --baseline-branch and --comparison-branch ) "
67+ + "or ( --baseline-tag and --comparison-tag ) args"
68+ )
69+ exit (1 )
70+ if use_branch is True and use_tag is True :
71+ logging .error (
72+ + "( --baseline-branch and --comparison-branch ) "
73+ + "and ( --baseline-tag and --comparison-tag ) args are mutually exclusive"
74+ )
75+ exit (1 )
4676 metric_name = args .metric_name
4777 metric_mode = args .metric_mode
4878 (
@@ -86,22 +116,24 @@ def compare_command_logic(args, project_name, project_version):
86116 for test_name in test_names :
87117
88118 test_name = test_name .decode ()
89-
119+ deployment_name = deployment_type
90120 ts_name_baseline = get_ts_metric_name (
91- "by.branch" ,
92- baseline_branch ,
121+ "by.{}" . format ( by_str ) ,
122+ baseline_str ,
93123 tf_github_org ,
94124 tf_github_repo ,
125+ deployment_name ,
95126 deployment_type ,
96127 test_name ,
97128 tf_triggering_env ,
98129 metric_name ,
99130 )
100131 ts_name_comparison = get_ts_metric_name (
101- "by.branch" ,
102- comparison_branch ,
132+ "by.{}" . format ( by_str ) ,
133+ comparison_str ,
103134 tf_github_org ,
104135 tf_github_repo ,
136+ deployment_name ,
105137 deployment_type ,
106138 test_name ,
107139 tf_triggering_env ,
@@ -156,12 +188,13 @@ def compare_command_logic(args, project_name, project_version):
156188 total_stable = total_stable + 1
157189
158190 if args .print_regressions_only is False or detected_regression :
191+ percentage_change_str = "{:.2f}" .format (percentage_change )
159192 profilers_artifacts_matrix .append (
160193 [
161194 test_name ,
162195 baseline_v ,
163196 comparison_v ,
164- percentage_change ,
197+ percentage_change_str ,
165198 ]
166199 )
167200
@@ -188,13 +221,13 @@ def compare_command_logic(args, project_name, project_version):
188221 )
189222 if total_improvements > 0 :
190223 logging .info (
191- "Detected a total of {} improvements above the improvement water line (> {} % %)" .format (
224+ "Detected a total of {} improvements above the improvement water line (> {}%)" .format (
192225 total_improvements , args .regressions_percent_lower_limit
193226 )
194227 )
195228 if total_regressions > 0 :
196229 logging .warning (
197- "Detected a total of {} regressions bellow the regression water line (< -{} % %)" .format (
230+ "Detected a total of {} regressions bellow the regression water line (< -{}%)" .format (
198231 total_regressions , args .regressions_percent_lower_limit
199232 )
200233 )
0 commit comments