Skip to content

Commit

Permalink
added Geekbench 6 as default test; refactored geekbench code
Browse files Browse the repository at this point in the history
  • Loading branch information
masonr committed Feb 28, 2023
1 parent e4e65d2 commit 06eaa2a
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 100 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

### 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:

Expand All @@ -43,9 +43,11 @@ curl -sL yabs.sh | bash -s -- -flags
* `-g` this option disables the Geekbench (system performance) test
* `-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
* `-r` this option reduces the number of iperf locations (Online.net/Clouvider LON+NYC) to lessen bandwidth usage
* `-4` this option overrides the Geekbench 5 performance test and runs a Geekbench 4 test instead
* `-9` this option runs the Geekbench 4 test in addition to the Geekbench 5 test
* `-r` this option reduces the number of iperf locations (Scaleway/Clouvider LON+NYC) to lessen bandwidth usage
* `-4` this option runs a Geekbench 4 test and disables the Geekbench 6 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
* `-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)
Expand All @@ -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).
* **[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

Expand Down
196 changes: 101 additions & 95 deletions yabs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# overall system performance via Geekbench 4/5, and random disk
# performance via fio. The script is designed to not require any dependencies
# - either compiled or installed - nor admin privileges to run.
#
YABS_VERSION="v2023-02-26"

YABS_VERSION="v2023-02-27"

echo -e '# ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #'
echo -e '# Yet-Another-Bench-Script #'
Expand Down Expand Up @@ -59,11 +59,11 @@ else
fi

# 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
GEEKBENCH_5="True" # gb5 test enabled by default
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_6="True" # gb6 test enabled by default

# 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
b) PREFER_BIN="True" ;;
f) SKIP_FIO="True" ;;
Expand All @@ -73,8 +73,10 @@ while getopts 'bfdignhr49jw:s:' flag; do
n) SKIP_NET="True" ;;
h) PRINT_HELP="True" ;;
r) REDUCE_NET="True" ;;
4) GEEKBENCH_4="True" && unset GEEKBENCH_5 ;;
9) GEEKBENCH_4="True" && GEEKBENCH_5="True" ;;
4) GEEKBENCH_4="True" && unset GEEKBENCH_6 ;;
5) GEEKBENCH_5="True" && unset GEEKBENCH_6 ;;
9) GEEKBENCH_4="True" && GEEKBENCH_5="True" && unset GEEKBENCH_6 ;;
6) GEEKBENCH_6="True" ;;
j) JSON+="j" ;;
w) JSON+="w" && JSON_FILE=${OPTARG} ;;
s) JSON+="s" && JSON_SEND=${OPTARG} ;;
Expand Down Expand Up @@ -121,8 +123,10 @@ if [ ! -z "$PRINT_HELP" ]; then
echo -e " then exits"
echo -e " -r : reduce number of iperf3 network locations (to only three)"
echo -e " to lessen bandwidth usage"
echo -e " -4 : use geekbench 4 instead of geekbench 5"
echo -e " -9 : use both geekbench 4 AND geekbench 5"
echo -e " -4 : use geekbench 4 instead of geekbench 6"
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 " -w <filename> : write jsonified YABS results to disk using file name provided"
echo -e " -s <url> : send jsonified YABS results to URL"
Expand All @@ -138,6 +142,7 @@ if [ ! -z "$PRINT_HELP" ]; then
[[ ! -z $REDUCE_NET ]] && echo -e " -r, using reduced (3) iperf3 locations"
[[ ! -z $GEEKBENCH_4 ]] && echo -e " running geekbench 4"
[[ ! -z $GEEKBENCH_5 ]] && echo -e " running geekbench 5"
[[ ! -z $GEEKBENCH_6 ]] && echo -e " running geekbench 6"
echo -e
echo -e "Local Binary Check:"
[[ -z $LOCAL_FIO ]] && echo -e " fio not detected, will download precompiled binary" ||
Expand Down Expand Up @@ -280,7 +285,7 @@ function ip_info() {
local as=$(echo "$response" | grep -Po '"as": *\K"[^"]*"')
local as=${as//\"}
if [[ -n "$net_type" ]]; then
echo "Protocol : $net_type"
fi
Expand Down Expand Up @@ -847,98 +852,95 @@ function launch_geekbench {
GEEKBENCH_PATH=$YABS_PATH/geekbench_$VERSION
mkdir -p $GEEKBENCH_PATH

GB_URL=""
GB_CMD=""
GB_RUN=""

# check for curl vs wget
[[ ! -z $LOCAL_CURL ]] && DL_CMD="curl -s" || DL_CMD="wget -qO-"

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
echo -en "\nRunning GB4 benchmark test... *cue elevator music*"
# download the latest Geekbench 4 tarball and extract to geekbench temp directory
$DL_CMD https://cdn.geekbench.com/Geekbench-4.4.4-Linux.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null

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")
GB_URL="https://cdn.geekbench.com/Geekbench-4.4.4-Linux.tar.gz"
[[ "$ARCH" == *"x86"* ]] && GB_CMD="geekbench_x86_32" || GB_CMD="geekbench4"
GB_RUN="True"
elif [[ $VERSION == *5* || $VERSION == *6* ]]; then # Geekbench v5/6
if [[ $ARCH = *x86* && $GEEKBENCH_4 == *False* ]]; then # don't run Geekbench 5 if on 32-bit arch
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 $VERSION."
elif [[ $ARCH = *x86* && $GEEKBENCH_4 == *True* ]]; then
echo -e "\nGeekbench $VERSION cannot run on 32-bit architectures. Skipping test."
else
# check if geekbench file exists
if test -f "geekbench.license"; then
$GEEKBENCH_PATH/geekbench4 --unlock $(cat geekbench.license) > /dev/null 2>&1
if [[ $VERSION == *5* ]]; then # Geekbench v5
[[ $ARCH = *aarch64* || $ARCH = *arm* ]] && GB_URL="https://cdn.geekbench.com/Geekbench-5.5.1-LinuxARMPreview.tar.gz" \
|| GB_URL="https://cdn.geekbench.com/Geekbench-5.5.1-Linux.tar.gz"
GB_CMD="geekbench5"
else # Geekbench v6
[[ $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

# 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")
GB_RUN="True"
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
echo -e "\nGeekbench 5 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."
elif [[ $ARCH = *x86* && $GEEKBENCH_4 == *True* ]]; then
echo -e "\nGeekbench 5 cannot run on 32-bit architectures. Skipping test."
else
echo -en "\nRunning GB5 benchmark test... *cue elevator music*"
# download the latest Geekbench 5 tarball and extract to geekbench temp directory
if [[ $ARCH = *aarch64* || $ARCH = *arm* ]]; then
$DL_CMD https://cdn.geekbench.com/Geekbench-5.5.1-LinuxARMPreview.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null
else
$DL_CMD https://cdn.geekbench.com/Geekbench-5.5.1-Linux.tar.gz | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null
if [[ $GB_RUN == *True* ]]; then # run GB test
echo -en "\nRunning GB$VERSION benchmark test... *cue elevator music*"

# download the desired Geekbench tarball and extract to geekbench temp directory
$DL_CMD $GB_URL | tar xz --strip-components=1 -C $GEEKBENCH_PATH &>/dev/null

# unlock if license file detected
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"

# check if geekbench file exists
if test -f "geekbench.license"; then
$GEEKBENCH_PATH/geekbench5 --unlock $(cat geekbench.license) > /dev/null 2>&1
if [ ! -z $JSON ]; then
JSON_RESULT+='{"version":'$VERSION',"single":'$GEEKBENCH_SCORES_SINGLE',"multi":'$GEEKBENCH_SCORES_MULTI
JSON_RESULT+=',"url":"'$GEEKBENCH_URL'"},'
fi

GEEKBENCH_TEST=$($GEEKBENCH_PATH/geekbench5 --upload 2>/dev/null | grep "https://browser")
fi
fi

# 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 [[ $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
JSON_RESULT+='{"version":'$VERSION',"single":'$GEEKBENCH_SCORES_SINGLE',"multi":'$GEEKBENCH_SCORES_MULTI
JSON_RESULT+=',"url":"'$GEEKBENCH_URL'"},'
# 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

# 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
}

Expand All @@ -952,6 +954,10 @@ if [ -z "$SKIP_GEEKBENCH" ]; then
if [[ $GEEKBENCH_5 == *True* ]]; then
launch_geekbench 5
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 ]] && JSON_RESULT+=']'
fi
Expand All @@ -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.
# Parameters:
# 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() {
end_time=$1
start_time=$2

time_taken=$(( ${end_time} - ${start_time} ))
if [ ${time_taken} -gt 60 ]; then
min=$(expr $time_taken / 60)
sec=$(expr $time_taken % 60)
echo "YABS completed in ${min} min ${sec} sec"
else
echo "YABS completed in ${time_taken} sec"
fi
if [ ${time_taken} -gt 60 ]; then
min=$(expr $time_taken / 60)
sec=$(expr $time_taken % 60)
echo "YABS completed in ${min} min ${sec} sec"
else
echo "YABS completed in ${time_taken} sec"
fi
}

calculate_time_taken $YABS_END_TIME $YABS_START_TIME
Expand Down

0 comments on commit 06eaa2a

Please sign in to comment.