Merge pull request #9821 from GabyCT/topic/fixts

metrics: Use function definition to have uniformity
This commit is contained in:
GabyCT 2024-06-12 10:04:28 -06:00 committed by GitHub
commit 461b6e7c93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -252,7 +252,7 @@ function init() {
} }
# Computes the average of the data # Computes the average of the data
calc_avg_array() { function calc_avg_array() {
data=("$@") data=("$@")
avg=0 avg=0
LSCALE=6 LSCALE=6
@ -268,7 +268,7 @@ calc_avg_array() {
# Computes the standard deviation of the data # Computes the standard deviation of the data
calc_sd_array() { function calc_sd_array() {
data=("$@") data=("$@")
sum_sqr_n=0 sum_sqr_n=0
size="${#data[@]}" size="${#data[@]}"
@ -315,7 +315,7 @@ calc_sd_array() {
# Computes the Coefficient of variation. # Computes the Coefficient of variation.
# The result is given as percentage. # The result is given as percentage.
calc_cov_array() { function calc_cov_array() {
sd=$1 sd=$1
mean=$2 mean=$2
@ -342,7 +342,7 @@ calc_cov_array() {
# Writes a JSON with the statistics results # Writes a JSON with the statistics results
# for each launch time metric # for each launch time metric
write_stats_results() { function write_stats_results() {
size="${#total_result_ds[@]}" size="${#total_result_ds[@]}"
avg_total_result=$(calc_avg_array "${total_result_ds[@]}") avg_total_result=$(calc_avg_array "${total_result_ds[@]}")
avg_to_workload=$(calc_avg_array "${to_workload_ds[@]}") avg_to_workload=$(calc_avg_array "${to_workload_ds[@]}")
@ -396,7 +396,7 @@ EOF
metrics_json_add_array_element "$json" metrics_json_add_array_element "$json"
} }
help() { function help() {
usage=$(cat << EOF usage=$(cat << EOF
Usage: $0 [-h] [options] Usage: $0 [-h] [options]
Description: Description:
@ -412,7 +412,7 @@ EOF
echo "$usage" echo "$usage"
} }
main() { function main() {
local OPTIND local OPTIND
while getopts "dhi:n:s" opt;do while getopts "dhi:n:s" opt;do
case ${opt} in case ${opt} in