4
4
# All rights reserved.
5
5
#
6
6
import logging
7
+ import re
8
+
7
9
import pandas as pd
8
10
import redis
9
11
from pytablewriter import MarkdownTableWriter
10
12
import humanize
11
13
import datetime as dt
12
-
14
+ from tqdm import tqdm
13
15
from redisbench_admin .utils .remote import get_overall_dashboard_keynames
14
16
15
17
16
- from redisbench_admin .utils .utils import get_ts_metric_name
17
-
18
-
19
18
def compare_command_logic (args , project_name , project_version ):
20
19
logging .info (
21
20
"Using: {project_name} {project_version}" .format (
@@ -99,29 +98,46 @@ def compare_command_logic(args, project_name, project_version):
99
98
_ ,
100
99
_ ,
101
100
_ ,
102
- _ ,
101
+ testcases_metric_context_path_setname ,
103
102
_ ,
104
103
_ ,
105
104
_ ,
106
105
_ ,
107
106
_ ,
108
107
) = get_overall_dashboard_keynames (tf_github_org , tf_github_repo , tf_triggering_env )
109
108
test_names = []
109
+ used_key = testcases_setname
110
+ test_filter = "test_name"
111
+
112
+ if args .use_metric_context_path :
113
+ test_filter = "test_name:metric_context_path"
114
+ used_key = testcases_metric_context_path_setname
115
+
116
+ tags_regex_string = re .compile (args .testname_regex )
117
+
110
118
try :
111
- test_names = rts .smembers (testcases_setname )
119
+ test_names = rts .smembers (used_key )
112
120
test_names = list (test_names )
113
121
test_names .sort ()
122
+ final_test_names = []
123
+ for test_name in test_names :
124
+ test_name = test_name .decode ()
125
+ match_obj = re .search (tags_regex_string , test_name )
126
+ if match_obj is not None :
127
+ final_test_names .append (test_name )
128
+ test_names = final_test_names
129
+
114
130
except redis .exceptions .ResponseError as e :
115
131
logging .warning (
116
132
"Error while trying to fetch test cases set (key={}) {}. " .format (
117
- testcases_setname , e .__str__ ()
133
+ used_key , e .__str__ ()
118
134
)
119
135
)
120
136
pass
121
137
122
138
logging .warning (
123
- "Based on test-cases set (key={}) we have {} distinct benchmarks . " .format (
124
- testcases_setname , len (test_names )
139
+ "Based on test-cases set (key={}) we have {} comparison points . " .format (
140
+ used_key , len (test_names )
125
141
)
126
142
)
127
143
profilers_artifacts_matrix = []
@@ -131,31 +147,42 @@ def compare_command_logic(args, project_name, project_version):
131
147
total_unstable = 0
132
148
total_regressions = 0
133
149
noise_waterline = 2.5
150
+ progress = tqdm (unit = "benchmark time-series" , total = len (test_names ))
134
151
for test_name in test_names :
152
+ filters_baseline = [
153
+ "{}={}" .format (by_str , baseline_str ),
154
+ "metric={}" .format (metric_name ),
155
+ "{}={}" .format (test_filter , test_name ),
156
+ "deployment_type={}" .format (deployment_type ),
157
+ "deployment_name={}" .format (deployment_name ),
158
+ ]
159
+ filters_comparison = [
160
+ "{}={}" .format (by_str , comparison_str ),
161
+ "metric={}" .format (metric_name ),
162
+ "{}={}" .format (test_filter , test_name ),
163
+ "deployment_type={}" .format (deployment_type ),
164
+ "deployment_name={}" .format (deployment_name ),
165
+ ]
166
+ baseline_timeseries = rts .ts ().queryindex (filters_baseline )
167
+ comparison_timeseries = rts .ts ().queryindex (filters_comparison )
168
+ progress .update ()
169
+ if len (baseline_timeseries ) != 1 :
170
+ if args .verbose :
171
+ logging .warning (
172
+ "Baseline timeseries {}" .format (len (baseline_timeseries ))
173
+ )
174
+ continue
175
+ else :
176
+ ts_name_baseline = baseline_timeseries [0 ]
177
+ if len (comparison_timeseries ) != 1 :
178
+ if args .verbose :
179
+ logging .warning (
180
+ "Comparison timeseries {}" .format (len (comparison_timeseries ))
181
+ )
182
+ continue
183
+ else :
184
+ ts_name_comparison = comparison_timeseries [0 ]
135
185
136
- test_name = test_name .decode ()
137
- ts_name_baseline = get_ts_metric_name (
138
- "by.{}" .format (by_str ),
139
- baseline_str ,
140
- tf_github_org ,
141
- tf_github_repo ,
142
- deployment_name ,
143
- deployment_type ,
144
- test_name ,
145
- tf_triggering_env ,
146
- metric_name ,
147
- )
148
- ts_name_comparison = get_ts_metric_name (
149
- "by.{}" .format (by_str ),
150
- comparison_str ,
151
- tf_github_org ,
152
- tf_github_repo ,
153
- deployment_name ,
154
- deployment_type ,
155
- test_name ,
156
- tf_triggering_env ,
157
- metric_name ,
158
- )
159
186
baseline_v = "N/A"
160
187
comparison_v = "N/A"
161
188
baseline_nsamples = 0
@@ -223,14 +250,14 @@ def compare_command_logic(args, project_name, project_version):
223
250
unstable = True
224
251
if baseline_pct_change > 10.0 :
225
252
stamp_b = "UNSTABLE"
226
- baseline_v_str = " {:.3f } +- {:.1f}% {}" .format (
227
- baseline_v , baseline_pct_change , stamp_b
253
+ baseline_v_str = " {:.0f } +- {:.1f}% {} ({} datapoints) " .format (
254
+ baseline_v , baseline_pct_change , stamp_b , baseline_nsamples
228
255
)
229
256
stamp_c = ""
230
257
if comparison_pct_change > 10.0 :
231
258
stamp_c = "UNSTABLE"
232
- comparison_v_str = " {:.3f } +- {:.1f}% {}" .format (
233
- comparison_v , comparison_pct_change , stamp_c
259
+ comparison_v_str = " {:.0f } +- {:.1f}% {} ({} datapoints) " .format (
260
+ comparison_v , comparison_pct_change , stamp_c , comparison_nsamples
234
261
)
235
262
if metric_mode == "higher-better" :
236
263
percentage_change = (
@@ -252,6 +279,8 @@ def compare_command_logic(args, project_name, project_version):
252
279
note = note + " REGRESSION"
253
280
elif percentage_change < - noise_waterline :
254
281
note = note + " potential REGRESSION"
282
+ else :
283
+ note = note + " -- no change --"
255
284
detected_regressions .append (test_name )
256
285
if percentage_change > 0.0 and not unstable :
257
286
if percentage_change > waterline :
@@ -260,6 +289,8 @@ def compare_command_logic(args, project_name, project_version):
260
289
note = note + " IMPROVEMENT"
261
290
elif percentage_change > noise_waterline :
262
291
note = note + " potential IMPROVEMENT"
292
+ else :
293
+ note = note + " -- no change --"
263
294
264
295
if (
265
296
detected_improvement is False
0 commit comments