From: danielhanrahan Date: Thu, 1 Aug 2024 10:14:13 +0000 (+0100) Subject: [CPS] Adjust k6 plots to have 20% padding X-Git-Url: https://gerrit.nordix.org/gitweb?a=commitdiff_plain;h=ea51278c04e6e3ccb24dc56c54f73aa968154b52;p=infra%2Fcicd.git [CPS] Adjust k6 plots to have 20% padding Set the max Y value in plots to be 20% higher than the max recorded value or limit in the CSV data file. Issue-ID: CPS-2208 Change-Id: I63b9f4c566f07507593f6f0c8d36e317d3525789 Signed-off-by: danielhanrahan --- diff --git a/jjb/onap/cps/prepare-k6-performance-tests-plots.sh b/jjb/onap/cps/prepare-k6-performance-tests-plots.sh index df6c5741..06a8eda5 100755 --- a/jjb/onap/cps/prepare-k6-performance-tests-plots.sh +++ b/jjb/onap/cps/prepare-k6-performance-tests-plots.sh @@ -94,9 +94,7 @@ buildPlotImage() { chartFileName="$2" units="$3" - # Set upper limit of the graphs to 20% bigger than largest limit to have more space above the plot - limit=$(cut -d, -f2 "$dataFile" | sort -n | tail -n 1) - limit=$(echo "$limit * 1.2" | bc) + y_max=$(findMaxPlotRange "$dataFile") # Create a temporary Gnuplot script cat <gnuplot_script.gp @@ -105,7 +103,7 @@ set terminal pngcairo size 1500,600 set output "${chartFileName}" set xlabel "Build" set ylabel "${units}" -set yrange [0 : ${limit} < *] +set yrange [0 : ${y_max} < *] set xtics rotate plot '$dataFile' using 1:3:xtic(sprintf("%d", column(1))) with linespoints title "measured", \ '$dataFile' using 1:2 with lines linestyle 2 title "limit" @@ -118,6 +116,16 @@ EOT rm gnuplot_script.gp } +# Set upper limit of the graphs to 20% bigger than largest value to have more space above the plot +findMaxPlotRange() { + dataFile="$1" + awk -F, '{ + if ($2 > max) max = $2; + if ($3 > max) max = $3; + } END { + print max * 1.2; + }' "$dataFile" +} ############################################################################################################################# ################################################ M A I N #################################################################### #############################################################################################################################