@@ -11,7 +11,7 @@ NC='\033[0m' # No Color
1111
1212SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
1313OUTPUT_FILE=" ${1:- $SCRIPT_DIR / performance-data.json} "
14- NUM_RUNS=3
14+ NUM_RUNS=5
1515
1616echo -e " ${BLUE} ========================================${NC} "
1717echo -e " ${BLUE} k6 Performance Test Collector${NC} "
@@ -21,24 +21,26 @@ echo "Output file: $OUTPUT_FILE"
2121echo " Running each test ${NUM_RUNS} times to reduce variance"
2222echo " "
2323
24- # Function to calculate median of 3 values
24+ # Function to calculate median from multiple values
2525calculate_median () {
2626 local values=(" $@ " )
27+ local count=${# values[@]}
2728 # Sort the values
2829 IFS=$' \n ' sorted=($( sort -n <<< " ${values[*]}" ) )
2930 unset IFS
30- # Return the middle value
31- echo " ${sorted[1]} "
31+ # Return the middle value (for odd number of values)
32+ local middle_index=$(( (count - 1 ) / 2 ))
33+ echo " ${sorted[$middle_index]} "
3234}
3335
34- # Run single-fetch test 3 times
36+ # Run single-fetch test multiple times
3537echo -e " ${BLUE} Running Single Fetch Test (${NUM_RUNS} runs)...${NC} "
3638for i in $( seq 1 $NUM_RUNS ) ; do
3739 echo -e " ${YELLOW} Run $i /$NUM_RUNS ${NC} "
3840 k6 run --summary-export=/tmp/single-fetch-summary-${i} .json " $SCRIPT_DIR /single-fetch.js"
3941done
4042
41- # Run dataloader test 3 times
43+ # Run dataloader test multiple times
4244echo -e " ${BLUE} Running DataLoader Test (${NUM_RUNS} runs)...${NC} "
4345for i in $( seq 1 $NUM_RUNS ) ; do
4446 echo -e " ${YELLOW} Run $i /$NUM_RUNS ${NC} "
0 commit comments