@@ -135,10 +135,31 @@ def compare_command_logic(args, project_name, project_version):
135135 last_n_baseline = args .last_n_baseline
136136 if last_n_comparison < 0 :
137137 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+
142163 verbose = args .verbose
143164 regressions_percent_lower_limit = args .regressions_percent_lower_limit
144165 metric_name = args .metric_name
@@ -280,6 +301,8 @@ def compare_command_logic(args, project_name, project_version):
280301 running_platform ,
281302 baseline_architecture ,
282303 comparison_architecture ,
304+ first_n_baseline ,
305+ first_n_comparison ,
283306 )
284307 comment_body = ""
285308 if total_comparison_points > 0 :
@@ -506,6 +529,8 @@ def compute_regression_table(
506529 running_platform = None ,
507530 baseline_architecture = ARCH_X86 ,
508531 comparison_architecture = ARCH_X86 ,
532+ first_n_baseline = - 1 ,
533+ first_n_comparison = - 1 ,
509534):
510535 START_TIME_NOW_UTC , _ , _ = get_start_time_vars ()
511536 START_TIME_LAST_MONTH_UTC = START_TIME_NOW_UTC - datetime .timedelta (days = 31 )
@@ -594,6 +619,8 @@ def compute_regression_table(
594619 running_platform ,
595620 baseline_architecture ,
596621 comparison_architecture ,
622+ first_n_baseline ,
623+ first_n_comparison ,
597624 )
598625 logging .info (
599626 "Printing differential analysis between {} and {}" .format (
@@ -723,6 +750,8 @@ def from_rts_to_regression_table(
723750 running_platform = None ,
724751 baseline_architecture = ARCH_X86 ,
725752 comparison_architecture = ARCH_X86 ,
753+ first_n_baseline = - 1 ,
754+ first_n_comparison = - 1 ,
726755):
727756 print_all = print_regressions_only is False and print_improvements_only is False
728757 table = []
@@ -835,6 +864,7 @@ def from_rts_to_regression_table(
835864 largest_variance ,
836865 last_n_baseline ,
837866 verbose ,
867+ first_n_baseline ,
838868 )
839869 for ts_name_comparison in comparison_timeseries :
840870 datapoints_inner = rts .ts ().revrange (
@@ -854,6 +884,7 @@ def from_rts_to_regression_table(
854884 largest_variance ,
855885 last_n_comparison ,
856886 verbose ,
887+ first_n_comparison ,
857888 )
858889
859890 waterline = regressions_percent_lower_limit
@@ -1051,13 +1082,25 @@ def get_v_pct_change_and_largest_var(
10511082 largest_variance ,
10521083 last_n = - 1 ,
10531084 verbose = False ,
1085+ first_n = - 1 ,
10541086):
10551087 comparison_nsamples = len (comparison_datapoints )
10561088 if comparison_nsamples > 0 :
10571089 _ , 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+
10611104 comparison_df = pd .DataFrame (comparison_values )
10621105 comparison_median = float (comparison_df .median ())
10631106 comparison_v = comparison_median
0 commit comments