@@ -22,12 +22,15 @@ compare_stat_p90() {
2222 local current_value=" $2 "
2323 local stat_name=" $3 "
2424
25- # Calculate 110 % of the past value
25+ # Calculate 115 % of the past value
2626 local threshold=$( calculate_threshold " $past_value " )
2727
28+ echo " Current P90 value for $stat_name : $current_value "
29+ # echo "Past P90 value for $stat_name: $past_value"
30+ echo " Threshold for $stat_name : $threshold "
2831 # Compare the current value with the threshold
29- if (( $(awk 'BEGIN {print ("'" $current_value "'" > "'" $threshold "'")}' ) )) ; then
30- echo " ERROR: $stat_name - Current P90 value ($current_value ) exceeds the 110 % threshold ($threshold ) of the past P90 value ($past_value )"
32+ if (( $(echo " $current_value > $current_value " | bc - l ) )) ; then
33+ echo " ERROR: $stat_name - Current P90 value ($current_value ) exceeds the 115 % threshold ($current_value ) of the past P90 value ($past_value )"
3134 return 1
3235 fi
3336
@@ -36,7 +39,18 @@ compare_stat_p90() {
3639
3740calculate_threshold () {
3841 local past_value=" $1 "
39- awk -v past=" $past_value " ' BEGIN { print past * 1.1 }'
42+ awk -v past=" $past_value " ' BEGIN { print past * 1.15 }'
43+ }
44+
45+ calculate_p90_after_skip () {
46+ local times_array=" $1 "
47+ local num_entries=$( echo " $times_array " | jq ' length' )
48+ local times=$( echo " $times_array " | jq -r ' .[1:] | .[]' )
49+ local sorted_times=$( echo " $times " | tr ' \n' ' ' | xargs -n1 | sort -g)
50+ local index=$(( num_entries * 90 / 100 ))
51+
52+ local p90=$( echo " $sorted_times " | sed -n " ${index} p" )
53+ echo " $p90 "
4054}
4155
4256# Loop through each object in past.json and compare P90 values with current.json for all statistics
@@ -52,8 +66,10 @@ compare_p90_values() {
5266 for test_name in $test_names ; do
5367 echo " Checking for regression in '$test_name '"
5468 for stat_name in " fullRunStats" " pullStats" " lazyTaskStats" " localTaskStats" ; do
55- local past_p90=$( echo " $past_json " | jq -r --arg test " $test_name " ' .benchmarkTests[] | select(.testName == $test) | .' " $stat_name " ' .pct90' )
56- local current_p90=$( echo " $current_json " | jq -r --arg test " $test_name " ' .benchmarkTests[] | select(.testName == $test) | .' " $stat_name " ' .pct90' )
69+ local past_p90_array=$( echo " $past_json " | jq -r --arg test " $test_name " ' .benchmarkTests[] | select(.testName == $test) | .' " $stat_name " ' .BenchmarkTimes' )
70+ local past_p90=$( calculate_p90_after_skip " $past_p90_array " )
71+ local current_p90_array=$( echo " $current_json " | jq -r --arg test " $test_name " ' .benchmarkTests[] | select(.testName == $test) | .' " $stat_name " ' .BenchmarkTimes' )
72+ local current_p90=$( calculate_p90_after_skip " $current_p90_array " )
5773
5874 # Call the compare_stat_p90 function
5975 compare_stat_p90 " $past_p90 " " $current_p90 " " $stat_name " || regression_detected=1
@@ -64,8 +80,6 @@ compare_p90_values() {
6480 return $regression_detected
6581}
6682
67- # ... (remaining code)
68-
6983# Call compare_p90_values and store the exit code in a variable
7084compare_p90_values " $past_data " " $current_data "
7185exit_code=$?
0 commit comments