added Geekbench 6 as default test; refactored geekbench code

This commit is contained in:
Mason Rowe 2023-02-28 01:43:09 +00:00
parent e4e65d2e87
commit 06eaa2ab3b
2 changed files with 109 additions and 101 deletions

View File

@ -29,7 +29,7 @@ This script has been tested on the following Linux distributions: CentOS 6+, Deb
**High Bandwidth Usage Notice**: By default, this script will perform many iperf network tests, which will try to max out the network port for ~20s per location (10s in each direction). Low-bandwidth servers (such as a NAT VPS) should consider running this script with the `-r` flag (for reduced iperf locations) or the `-i` flag (to disable network tests entirely). **High Bandwidth Usage Notice**: By default, this script will perform many iperf network tests, which will try to max out the network port for ~20s per location (10s in each direction). Low-bandwidth servers (such as a NAT VPS) should consider running this script with the `-r` flag (for reduced iperf locations) or the `-i` flag (to disable network tests entirely).
### Flags (Skipping Tests, Reducing iperf Locations, Geekbench 4, etc.) ### Flags (Skipping Tests, Reducing iperf Locations, Geekbench 4/5/6, etc.)
By default, the script runs all three tests described in the next section below. In the event that you wish to skip one or more of the tests, use the commands below: By default, the script runs all three tests described in the next section below. In the event that you wish to skip one or more of the tests, use the commands below:
@ -43,9 +43,11 @@ curl -sL yabs.sh | bash -s -- -flags
* `-g` this option disables the Geekbench (system performance) test * `-g` this option disables the Geekbench (system performance) test
* `-n` this option skips the network information lookup and print out * `-n` this option skips the network information lookup and print out
* `-h` this option prints the help message with usage, flags detected, and local package (fio/iperf) status * `-h` this option prints the help message with usage, flags detected, and local package (fio/iperf) status
* `-r` this option reduces the number of iperf locations (Online.net/Clouvider LON+NYC) to lessen bandwidth usage * `-r` this option reduces the number of iperf locations (Scaleway/Clouvider LON+NYC) to lessen bandwidth usage
* `-4` this option overrides the Geekbench 5 performance test and runs a Geekbench 4 test instead * `-4` this option runs a Geekbench 4 test and disables the Geekbench 6 test
* `-9` this option runs the Geekbench 4 test in addition to the Geekbench 5 test * `-5` this option runs a Geekbench 5 test and disables the Geekbench 6 test
* `-9` this option runs both the Geekbench 4 and 5 tests instead of the Geekbench 6 test
* `-6` this option re-enables the Geekbench 6 test if any of the following were used: -4, -5, or -9 (-6 flag must be last to not be overridden)
* `-j` this option prints a JSON representation of the results to the screen * `-j` this option prints a JSON representation of the results to the screen
* `-w <filename>` this option writes the JSON results to a file using the file name provided * `-w <filename>` this option writes the JSON results to a file using the file name provided
* `-s <url>` this option sends a JSON representation of the results to the designated URL(s) (see section below) * `-s <url>` this option sends a JSON representation of the results to the designated URL(s) (see section below)
@ -70,7 +72,7 @@ A list of websites supporting acceptance of YABS JSON results will be posted her
* **[fio](https://github.com/axboe/fio)** - the most comprehensive I/O testing software available, fio grants the ability to evaluate disk performance in a variety of methods with a variety of options. Four random read and write fio disk tests are conducted as part of this script with 4k, 64k, 512k, and 1m block sizes. The tests are designed to evaluate disk throughput in near-real world (using random) scenarios with a 50/50 split (50% reads and 50% writes per test). * **[fio](https://github.com/axboe/fio)** - the most comprehensive I/O testing software available, fio grants the ability to evaluate disk performance in a variety of methods with a variety of options. Four random read and write fio disk tests are conducted as part of this script with 4k, 64k, 512k, and 1m block sizes. The tests are designed to evaluate disk throughput in near-real world (using random) scenarios with a 50/50 split (50% reads and 50% writes per test).
* **[iperf3](https://github.com/esnet/iperf)** - the industry standard for testing download and upload speeds to various locations. This script utilizes iperf3 with 8 parallel threads and tests both download and upload speeds. If an iperf server is busy after 5 tries, the speed test for that location/direction is skipped. * **[iperf3](https://github.com/esnet/iperf)** - the industry standard for testing download and upload speeds to various locations. This script utilizes iperf3 with 8 parallel threads and tests both download and upload speeds. If an iperf server is busy after 5 tries, the speed test for that location/direction is skipped.
* **[Geekbench](https://www.geekbench.com/)** - Geekbench is a benchmarking program that measures system performance, which is widely used in the tech community. The web URL is displayed to be able to see complete test and individual benchmark results and allow comparison to other geekbench'd systems. The claim URL to add the Geekbench result to your Geekbench profile is written to a file in the directory that this script is executed from. By default, Geekbench 5 is the only Geekbench test performed, however, Geekbench 4 can also be toggled on by passing the appropriate flag. * **[Geekbench](https://www.geekbench.com/)** - Geekbench is a benchmarking program that measures system performance, which is widely used in the tech community. The web URL is displayed to be able to see complete test and individual benchmark results and allow comparison to other geekbench'd systems. The claim URL to add the Geekbench result to your Geekbench profile is written to a file in the directory that this script is executed from. By default, Geekbench 6 is the only Geekbench test performed, however, Geekbench 4 and/or 5 can also be toggled on by passing the appropriate flag.
### Security Notice ### Security Notice

198
yabs.sh
View File

@ -11,8 +11,8 @@
# overall system performance via Geekbench 4/5, and random disk # overall system performance via Geekbench 4/5, and random disk
# performance via fio. The script is designed to not require any dependencies # performance via fio. The script is designed to not require any dependencies
# - either compiled or installed - nor admin privileges to run. # - either compiled or installed - nor admin privileges to run.
#
YABS_VERSION="v2023-02-26" YABS_VERSION="v2023-02-27"
echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #' echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
echo -e '# Yet-Another-Bench-Script #' echo -e '# Yet-Another-Bench-Script #'
@ -59,11 +59,11 @@ else
fi fi
# flags to skip certain performance tests # flags to skip certain performance tests
unset PREFER_BIN SKIP_FIO SKIP_IPERF SKIP_GEEKBENCH SKIP_NET PRINT_HELP REDUCE_NET GEEKBENCH_4 GEEKBENCH_5 DD_FALLBACK IPERF_DL_FAIL JSON JSON_SEND JSON_RESULT JSON_FILE unset PREFER_BIN SKIP_FIO SKIP_IPERF SKIP_GEEKBENCH SKIP_NET PRINT_HELP REDUCE_NET GEEKBENCH_4 GEEKBENCH_5 GEEKBENCH_6 DD_FALLBACK IPERF_DL_FAIL JSON JSON_SEND JSON_RESULT JSON_FILE
GEEKBENCH_5="True" # gb5 test enabled by default GEEKBENCH_6="True" # gb6 test enabled by default
# get any arguments that were passed to the script and set the associated skip flags (if applicable) # get any arguments that were passed to the script and set the associated skip flags (if applicable)
while getopts 'bfdignhr49jw:s:' flag; do while getopts 'bfdignhr4596jw:s:' flag; do
case "${flag}" in case "${flag}" in
b) PREFER_BIN="True" ;; b) PREFER_BIN="True" ;;
f) SKIP_FIO="True" ;; f) SKIP_FIO="True" ;;
@ -73,8 +73,10 @@ while getopts 'bfdignhr49jw:s:' flag; do
n) SKIP_NET="True" ;; n) SKIP_NET="True" ;;
h) PRINT_HELP="True" ;; h) PRINT_HELP="True" ;;
r) REDUCE_NET="True" ;; r) REDUCE_NET="True" ;;
4) GEEKBENCH_4="True" && unset GEEKBENCH_5 ;; 4) GEEKBENCH_4="True" && unset GEEKBENCH_6 ;;
9) GEEKBENCH_4="True" && GEEKBENCH_5="True" ;; 5) GEEKBENCH_5="True" && unset GEEKBENCH_6 ;;
9) GEEKBENCH_4="True" && GEEKBENCH_5="True" && unset GEEKBENCH_6 ;;
6) GEEKBENCH_6="True" ;;
j) JSON+="j" ;; j) JSON+="j" ;;
w) JSON+="w" && JSON_FILE=${OPTARG} ;; w) JSON+="w" && JSON_FILE=${OPTARG} ;;
s) JSON+="s" && JSON_SEND=${OPTARG} ;; s) JSON+="s" && JSON_SEND=${OPTARG} ;;
@ -121,8 +123,10 @@ if [ ! -z "$PRINT_HELP" ]; then
echo -e " then exits" echo -e " then exits"
echo -e " -r : reduce number of iperf3 network locations (to only three)" echo -e " -r : reduce number of iperf3 network locations (to only three)"
echo -e " to lessen bandwidth usage" echo -e " to lessen bandwidth usage"
echo -e " -4 : use geekbench 4 instead of geekbench 5" echo -e " -4 : use geekbench 4 instead of geekbench 6"
echo -e " -9 : use both geekbench 4 AND geekbench 5" echo -e " -5 : use geekbench 5 instead of geekbench 6"
echo -e " -9 : use both geekbench 4 AND geekbench 5 instead of geekbench 6"
echo -e " -6 : user geekbench 6 in addition to 4 and/or 5 (only needed if -4, -5, or -9 are set; -6 must come last)"
echo -e " -j : print jsonified YABS results at conclusion of test" echo -e " -j : print jsonified YABS results at conclusion of test"
echo -e " -w <filename> : write jsonified YABS results to disk using file name provided" echo -e " -w <filename> : write jsonified YABS results to disk using file name provided"
echo -e " -s <url> : send jsonified YABS results to URL" echo -e " -s <url> : send jsonified YABS results to URL"
@ -138,6 +142,7 @@ if [ ! -z "$PRINT_HELP" ]; then
[[ ! -z $REDUCE_NET ]] && echo -e " -r, using reduced (3) iperf3 locations" [[ ! -z $REDUCE_NET ]] && echo -e " -r, using reduced (3) iperf3 locations"
[[ ! -z $GEEKBENCH_4 ]] && echo -e " running geekbench 4" [[ ! -z $GEEKBENCH_4 ]] && echo -e " running geekbench 4"
[[ ! -z $GEEKBENCH_5 ]] && echo -e " running geekbench 5" [[ ! -z $GEEKBENCH_5 ]] && echo -e " running geekbench 5"
[[ ! -z $GEEKBENCH_6 ]] && echo -e " running geekbench 6"
echo -e echo -e
echo -e "Local Binary Check:" echo -e "Local Binary Check:"
[[ -z $LOCAL_FIO ]] && echo -e " fio not detected, will download precompiled binary" || [[ -z $LOCAL_FIO ]] && echo -e " fio not detected, will download precompiled binary" ||
@ -280,7 +285,7 @@ function ip_info() {
local as=$(echo "$response" | grep -Po '"as": *\K"[^"]*"') local as=$(echo "$response" | grep -Po '"as": *\K"[^"]*"')
local as=${as//\"} local as=${as//\"}
if [[ -n "$net_type" ]]; then if [[ -n "$net_type" ]]; then
echo "Protocol : $net_type" echo "Protocol : $net_type"
fi fi
@ -847,98 +852,95 @@ function launch_geekbench {
GEEKBENCH_PATH=$YABS_PATH/geekbench_$VERSION GEEKBENCH_PATH=$YABS_PATH/geekbench_$VERSION
mkdir -p $GEEKBENCH_PATH mkdir -p $GEEKBENCH_PATH
GB_URL=""
GB_CMD=""
GB_RUN=""
# check for curl vs wget # check for curl vs wget
[[ ! -z $LOCAL_CURL ]] && DL_CMD="curl -s" || DL_CMD="wget -qO-" [[ ! -z $LOCAL_CURL ]] && DL_CMD="curl -s" || DL_CMD="wget -qO-"
if [[ $VERSION == *4* && ($ARCH = *aarch64* || $ARCH = *arm*) ]]; then if [[ $VERSION == *4* && ($ARCH = *aarch64* || $ARCH = *arm*) ]]; then
echo -e "\nARM architecture not supported by Geekbench 4, use Geekbench 5." echo -e "\nARM architecture not supported by Geekbench 4, use Geekbench 5 or 6."
elif [[ $VERSION == *4* && $ARCH != *aarch64* && $ARCH != *arm* ]]; then # Geekbench v4 elif [[ $VERSION == *4* && $ARCH != *aarch64* && $ARCH != *arm* ]]; then # Geekbench v4
echo -en "\nRunning GB4 benchmark test... *cue elevator music*" GB_URL="https://cdn.geekbench.com/Geekbench-4.4.4-Linux.tar.gz"
# download the latest Geekbench 4 tarball and extract to geekbench temp directory [[ "$ARCH" == *"x86"* ]] && GB_CMD="geekbench_x86_32" || GB_CMD="geekbench4"
$DL_CMD https://cdn.geekbench.com/Geekbench-4.4.4-Linux.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null GB_RUN="True"
elif [[ $VERSION == *5* || $VERSION == *6* ]]; then # Geekbench v5/6
if [[ "$ARCH" == *"x86"* ]]; then
# check if geekbench file exists
if test -f "geekbench.license"; then
$GEEKBENCH_PATH/geekbench_x86_32 --unlock $(cat geekbench.license) > /dev/null 2>&1
fi
# run the Geekbench 4 test and grep the test results URL given at the end of the test
GEEKBENCH_TEST=$($GEEKBENCH_PATH/geekbench_x86_32 --upload 2>/dev/null | grep "https://browser")
else
# check if geekbench file exists
if test -f "geekbench.license"; then
$GEEKBENCH_PATH/geekbench4 --unlock $(cat geekbench.license) > /dev/null 2>&1
fi
# run the Geekbench 4 test and grep the test results URL given at the end of the test
GEEKBENCH_TEST=$($GEEKBENCH_PATH/geekbench4 --upload 2>/dev/null | grep "https://browser")
fi
fi
if [[ $VERSION == *5* ]]; then # Geekbench v5
if [[ $ARCH = *x86* && $GEEKBENCH_4 == *False* ]]; then # don't run Geekbench 5 if on 32-bit arch if [[ $ARCH = *x86* && $GEEKBENCH_4 == *False* ]]; then # don't run Geekbench 5 if on 32-bit arch
echo -e "\nGeekbench 5 cannot run on 32-bit architectures. Re-run with -4 flag to use" echo -e "\nGeekbench $VERSION cannot run on 32-bit architectures. Re-run with -4 flag to use"
echo -e "Geekbench 4, which can support 32-bit architectures. Skipping Geekbench 5." echo -e "Geekbench 4, which can support 32-bit architectures. Skipping Geekbench $VERSION."
elif [[ $ARCH = *x86* && $GEEKBENCH_4 == *True* ]]; then elif [[ $ARCH = *x86* && $GEEKBENCH_4 == *True* ]]; then
echo -e "\nGeekbench 5 cannot run on 32-bit architectures. Skipping test." echo -e "\nGeekbench $VERSION cannot run on 32-bit architectures. Skipping test."
else else
echo -en "\nRunning GB5 benchmark test... *cue elevator music*" if [[ $VERSION == *5* ]]; then # Geekbench v5
# download the latest Geekbench 5 tarball and extract to geekbench temp directory [[ $ARCH = *aarch64* || $ARCH = *arm* ]] && GB_URL="https://cdn.geekbench.com/Geekbench-5.5.1-LinuxARMPreview.tar.gz" \
if [[ $ARCH = *aarch64* || $ARCH = *arm* ]]; then || GB_URL="https://cdn.geekbench.com/Geekbench-5.5.1-Linux.tar.gz"
$DL_CMD https://cdn.geekbench.com/Geekbench-5.5.1-LinuxARMPreview.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null GB_CMD="geekbench5"
else else # Geekbench v6
$DL_CMD https://cdn.geekbench.com/Geekbench-5.5.1-Linux.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null [[ $ARCH = *aarch64* || $ARCH = *arm* ]] && GB_URL="https://cdn.geekbench.com/Geekbench-6.0.0-LinuxARMPreview.tar.gz" \
|| GB_URL="https://cdn.geekbench.com/Geekbench-6.0.0-Linux.tar.gz"
GB_CMD="geekbench6"
fi fi
GB_RUN="True"
# check if geekbench file exists
if test -f "geekbench.license"; then
$GEEKBENCH_PATH/geekbench5 --unlock $(cat geekbench.license) > /dev/null 2>&1
fi
GEEKBENCH_TEST=$($GEEKBENCH_PATH/geekbench5 --upload 2>/dev/null | grep "https://browser")
fi fi
fi fi
# ensure the test ran successfully if [[ $GB_RUN == *True* ]]; then # run GB test
if [ -z "$GEEKBENCH_TEST" ]; then echo -en "\nRunning GB$VERSION benchmark test... *cue elevator music*"
if [[ -z "$IPV4_CHECK" ]]; then
# Geekbench test failed to download because host lacks IPv4 (cdn.geekbench.com = IPv4 only)
echo -e "\r\033[0KGeekbench releases can only be downloaded over IPv4. FTP the Geekbench files and run manually."
elif [[ $ARCH != *x86* ]]; then
# if the Geekbench test failed for any reason, exit cleanly and print error message
echo -e "\r\033[0KGeekbench $VERSION test failed. Run manually to determine cause."
fi
else
# if the Geekbench test succeeded, parse the test results URL
GEEKBENCH_URL=$(echo -e $GEEKBENCH_TEST | head -1)
GEEKBENCH_URL_CLAIM=$(echo $GEEKBENCH_URL | awk '{ print $2 }')
GEEKBENCH_URL=$(echo $GEEKBENCH_URL | awk '{ print $1 }')
# sleep a bit to wait for results to be made available on the geekbench website
sleep 20
# parse the public results page for the single and multi core geekbench scores
[[ $VERSION == *5* ]] && GEEKBENCH_SCORES=$($DL_CMD $GEEKBENCH_URL | grep "div class='score'") ||
GEEKBENCH_SCORES=$($DL_CMD $GEEKBENCH_URL | grep "span class='score'")
GEEKBENCH_SCORES_SINGLE=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $3 }')
GEEKBENCH_SCORES_MULTI=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $7 }')
# print the Geekbench results
echo -en "\r\033[0K"
echo -e "Geekbench $VERSION Benchmark Test:"
echo -e "---------------------------------"
printf "%-15s | %-30s\n" "Test" "Value"
printf "%-15s | %-30s\n"
printf "%-15s | %-30s\n" "Single Core" "$GEEKBENCH_SCORES_SINGLE"
printf "%-15s | %-30s\n" "Multi Core" "$GEEKBENCH_SCORES_MULTI"
printf "%-15s | %-30s\n" "Full Test" "$GEEKBENCH_URL"
if [ ! -z $JSON ]; then # download the desired Geekbench tarball and extract to geekbench temp directory
JSON_RESULT+='{"version":'$VERSION',"single":'$GEEKBENCH_SCORES_SINGLE',"multi":'$GEEKBENCH_SCORES_MULTI $DL_CMD $GB_URL | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null
JSON_RESULT+=',"url":"'$GEEKBENCH_URL'"},'
fi
# write the geekbench claim URL to a file so the user can add the results to their profile (if desired) # unlock if license file detected
[ ! -z "$GEEKBENCH_URL_CLAIM" ] && echo -e "$GEEKBENCH_URL_CLAIM" >> geekbench_claim.url 2> /dev/null test -f "geekbench.license" && $GEEKBENCH_PATH/$GB_CMD --unlock $(cat geekbench.license) > /dev/null 2>&1
# run the Geekbench test and grep the test results URL given at the end of the test
GEEKBENCH_TEST=$($GEEKBENCH_PATH/$GB_CMD --upload 2>/dev/null | grep "https://browser")
# ensure the test ran successfully
if [ -z "$GEEKBENCH_TEST" ]; then
if [[ -z "$IPV4_CHECK" ]]; then
# Geekbench test failed to download because host lacks IPv4 (cdn.geekbench.com = IPv4 only)
echo -e "\r\033[0KGeekbench releases can only be downloaded over IPv4. FTP the Geekbench files and run manually."
elif [[ $VERSION != *4* && $TOTAL_RAM_RAW -le 1048576 ]]; then
# Geekbench 5/6 test failed with low memory (<=1GB)
echo -e "\r\033[0KGeekbench test failed and low memory was detected. Add at least 1GB of SWAP or use GB4 instead (higher compatibility with low memory systems)."
elif [[ $ARCH != *x86* ]]; then
# if the Geekbench test failed for any other reason, exit cleanly and print error message
echo -e "\r\033[0KGeekbench $VERSION test failed. Run manually to determine cause."
fi
else
# if the Geekbench test succeeded, parse the test results URL
GEEKBENCH_URL=$(echo -e $GEEKBENCH_TEST | head -1)
GEEKBENCH_URL_CLAIM=$(echo $GEEKBENCH_URL | awk '{ print $2 }')
GEEKBENCH_URL=$(echo $GEEKBENCH_URL | awk '{ print $1 }')
# sleep a bit to wait for results to be made available on the geekbench website
sleep 10
# parse the public results page for the single and multi core geekbench scores
[[ $VERSION == *4* ]] && GEEKBENCH_SCORES=$($DL_CMD $GEEKBENCH_URL | grep "span class='score'") || \
GEEKBENCH_SCORES=$($DL_CMD $GEEKBENCH_URL | grep "div class='score'")
GEEKBENCH_SCORES_SINGLE=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $3 }')
GEEKBENCH_SCORES_MULTI=$(echo $GEEKBENCH_SCORES | awk -v FS="(>|<)" '{ print $7 }')
# print the Geekbench results
echo -en "\r\033[0K"
echo -e "Geekbench $VERSION Benchmark Test:"
echo -e "---------------------------------"
printf "%-15s | %-30s\n" "Test" "Value"
printf "%-15s | %-30s\n"
printf "%-15s | %-30s\n" "Single Core" "$GEEKBENCH_SCORES_SINGLE"
printf "%-15s | %-30s\n" "Multi Core" "$GEEKBENCH_SCORES_MULTI"
printf "%-15s | %-30s\n" "Full Test" "$GEEKBENCH_URL"
if [ ! -z $JSON ]; then
JSON_RESULT+='{"version":'$VERSION',"single":'$GEEKBENCH_SCORES_SINGLE',"multi":'$GEEKBENCH_SCORES_MULTI
JSON_RESULT+=',"url":"'$GEEKBENCH_URL'"},'
fi
# write the geekbench claim URL to a file so the user can add the results to their profile (if desired)
[ ! -z "$GEEKBENCH_URL_CLAIM" ] && echo -e "$GEEKBENCH_URL_CLAIM" >> geekbench_claim.url 2> /dev/null
fi
fi fi
} }
@ -952,6 +954,10 @@ if [ -z "$SKIP_GEEKBENCH" ]; then
if [[ $GEEKBENCH_5 == *True* ]]; then if [[ $GEEKBENCH_5 == *True* ]]; then
launch_geekbench 5 launch_geekbench 5
fi fi
if [[ $GEEKBENCH_6 == *True* ]]; then
launch_geekbench 6
fi
[[ ! -z $JSON ]] && [[ $(echo -n $JSON_RESULT | tail -c 1) == ',' ]] && JSON_RESULT=${JSON_RESULT::${#JSON_RESULT}-1} [[ ! -z $JSON ]] && [[ $(echo -n $JSON_RESULT | tail -c 1) == ',' ]] && JSON_RESULT=${JSON_RESULT::${#JSON_RESULT}-1}
[[ ! -z $JSON ]] && JSON_RESULT+=']' [[ ! -z $JSON ]] && JSON_RESULT+=']'
fi fi
@ -966,19 +972,19 @@ YABS_END_TIME=$(date +%s)
# Purpose: This method is designed to find the time taken for the completion of a YABS run. # Purpose: This method is designed to find the time taken for the completion of a YABS run.
# Parameters: # Parameters:
# 1. YABS_END_TIME - time when GB has completed and all files are removed # 1. YABS_END_TIME - time when GB has completed and all files are removed
# 2. YABS_START_TIME - time when YABS is started # 2. YABS_START_TIME - time when YABS is started
function calculate_time_taken() { function calculate_time_taken() {
end_time=$1 end_time=$1
start_time=$2 start_time=$2
time_taken=$(( ${end_time} - ${start_time} )) time_taken=$(( ${end_time} - ${start_time} ))
if [ ${time_taken} -gt 60 ]; then if [ ${time_taken} -gt 60 ]; then
min=$(expr $time_taken / 60) min=$(expr $time_taken / 60)
sec=$(expr $time_taken % 60) sec=$(expr $time_taken % 60)
echo "YABS completed in ${min} min ${sec} sec" echo "YABS completed in ${min} min ${sec} sec"
else else
echo "YABS completed in ${time_taken} sec" echo "YABS completed in ${time_taken} sec"
fi fi
} }
calculate_time_taken $YABS_END_TIME $YABS_START_TIME calculate_time_taken $YABS_END_TIME $YABS_START_TIME