@@ -135,10 +135,31 @@ def compare_command_logic(args, project_name, project_version):
135
135
last_n_baseline = args .last_n_baseline
136
136
if last_n_comparison < 0 :
137
137
last_n_comparison = args .last_n_comparison
138
- logging .info ("Using last {} samples for baseline analysis" .format (last_n_baseline ))
139
- logging .info (
140
- "Using last {} samples for comparison analysis" .format (last_n_comparison )
141
- )
138
+ first_n_baseline = args .first_n_baseline
139
+ first_n_comparison = args .first_n_comparison
140
+ # Log the interval of values considered
141
+ if first_n_baseline >= 0 :
142
+ logging .info (
143
+ "Using samples in the range [{}:{}] for baseline analysis" .format (
144
+ first_n_baseline , last_n_baseline
145
+ )
146
+ )
147
+ else :
148
+ logging .info (
149
+ "Using last {} samples for baseline analysis" .format (last_n_baseline )
150
+ )
151
+
152
+ if first_n_comparison >= 0 :
153
+ logging .info (
154
+ "Using samples in the range [{}:{}] for comparison analysis" .format (
155
+ first_n_comparison , last_n_comparison
156
+ )
157
+ )
158
+ else :
159
+ logging .info (
160
+ "Using last {} samples for comparison analysis" .format (last_n_comparison )
161
+ )
162
+
142
163
verbose = args .verbose
143
164
regressions_percent_lower_limit = args .regressions_percent_lower_limit
144
165
metric_name = args .metric_name
@@ -280,6 +301,8 @@ def compare_command_logic(args, project_name, project_version):
280
301
running_platform ,
281
302
baseline_architecture ,
282
303
comparison_architecture ,
304
+ first_n_baseline ,
305
+ first_n_comparison ,
283
306
)
284
307
comment_body = ""
285
308
if total_comparison_points > 0 :
@@ -506,6 +529,8 @@ def compute_regression_table(
506
529
running_platform = None ,
507
530
baseline_architecture = ARCH_X86 ,
508
531
comparison_architecture = ARCH_X86 ,
532
+ first_n_baseline = - 1 ,
533
+ first_n_comparison = - 1 ,
509
534
):
510
535
START_TIME_NOW_UTC , _ , _ = get_start_time_vars ()
511
536
START_TIME_LAST_MONTH_UTC = START_TIME_NOW_UTC - datetime .timedelta (days = 31 )
@@ -594,6 +619,8 @@ def compute_regression_table(
594
619
running_platform ,
595
620
baseline_architecture ,
596
621
comparison_architecture ,
622
+ first_n_baseline ,
623
+ first_n_comparison ,
597
624
)
598
625
logging .info (
599
626
"Printing differential analysis between {} and {}" .format (
@@ -723,6 +750,8 @@ def from_rts_to_regression_table(
723
750
running_platform = None ,
724
751
baseline_architecture = ARCH_X86 ,
725
752
comparison_architecture = ARCH_X86 ,
753
+ first_n_baseline = - 1 ,
754
+ first_n_comparison = - 1 ,
726
755
):
727
756
print_all = print_regressions_only is False and print_improvements_only is False
728
757
table = []
@@ -835,6 +864,7 @@ def from_rts_to_regression_table(
835
864
largest_variance ,
836
865
last_n_baseline ,
837
866
verbose ,
867
+ first_n_baseline ,
838
868
)
839
869
for ts_name_comparison in comparison_timeseries :
840
870
datapoints_inner = rts .ts ().revrange (
@@ -854,6 +884,7 @@ def from_rts_to_regression_table(
854
884
largest_variance ,
855
885
last_n_comparison ,
856
886
verbose ,
887
+ first_n_comparison ,
857
888
)
858
889
859
890
waterline = regressions_percent_lower_limit
@@ -1051,13 +1082,25 @@ def get_v_pct_change_and_largest_var(
1051
1082
largest_variance ,
1052
1083
last_n = - 1 ,
1053
1084
verbose = False ,
1085
+ first_n = - 1 ,
1054
1086
):
1055
1087
comparison_nsamples = len (comparison_datapoints )
1056
1088
if comparison_nsamples > 0 :
1057
1089
_ , comparison_v = comparison_datapoints [0 ]
1058
- for tuple in comparison_datapoints :
1059
- if last_n < 0 or (last_n > 0 and len (comparison_values ) < last_n ):
1060
- comparison_values .append (tuple [1 ])
1090
+
1091
+ # Apply first_n and last_n boundaries
1092
+ start_idx = 0 if first_n < 0 else max (0 , min (first_n , comparison_nsamples ))
1093
+ end_idx = (
1094
+ comparison_nsamples
1095
+ if last_n < 0
1096
+ else max (0 , min (last_n , comparison_nsamples ))
1097
+ )
1098
+
1099
+ selected_data = comparison_datapoints [start_idx :end_idx ]
1100
+
1101
+ for tuple in selected_data :
1102
+ comparison_values .append (tuple [1 ])
1103
+
1061
1104
comparison_df = pd .DataFrame (comparison_values )
1062
1105
comparison_median = float (comparison_df .median ())
1063
1106
comparison_v = comparison_median
0 commit comments