added options to skip any test(s)

This commit is contained in:
Mason Rowe 2019-10-06 23:51:09 -04:00
parent eb0703500a
commit 9499aac6f7
2 changed files with 117 additions and 83 deletions

View File

@ -10,7 +10,22 @@ This script isn't an attempt to be a golden standard. It's just yet another benc
`curl -s https://raw.githubusercontent.com/masonr/yet-another-bench-script/master/yabs.sh | bash`
This script has been tested on CentOS 7, Debian 9, Debian 10, Fedora 30, Ubuntu 16.04, and Ubuntu 18.04. It is designed to not require any external dependencies nor elevated privileges.
This script has been tested on CentOS 7, Debian 9, Debian 10, Fedora 30, Ubuntu 16.04, and Ubuntu 18.04. It is designed to not require any external dependencies to be installed nor elevated privileges.
### Skipping Tests
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:
```
curl https://raw.githubusercontent.com/masonr/yet-another-bench-script/master/yabs.sh -o yabs.sh; chmod +x yabs.sh
./yabs.sh -{dig}
```
* `-d` this option disables the dd (disk performance) test
* `-i` this option disables the iperf (network performance) test
* `-g` this option disables the Geekbench (system performance) test
Options can be grouped together to skip multiple tests, i.e. `./yabs -dg` to skip the dd and Geekbench tests (effectively only performing the iperf test).
## Tests Conducted

37
yabs.sh
View File

@ -34,7 +34,18 @@ DATE=`date -Iseconds | sed -e "s/:/_/g"`
YABS_PATH=/tmp/$DATE/
mkdir -p $YABS_PATH
echo -e "Performing dd disk performance test. This may take a couple minutes to complete..."
SKIP_DD=""
SHIP_IPERF=""
SKIP_GEEKBENCH=""
while getopts 'dig' flag; do
case "${flag}" in
d) SKIP_DD="True" ;;
i) SKIP_IPERF="True" ;;
g) SKIP_GEEKBENCH="True" ;;
*) exit 1 ;;
esac
done
function dd_test {
I=0
@ -65,6 +76,9 @@ function dd_test {
DD_READ_TEST_AVG=$(awk -v a="$DD_READ_TEST_AVG" 'BEGIN { print a / 3 }')
}
if [ -z "$SKIP_DD" ]; then
echo -e "Performing dd disk performance test. This may take a couple minutes to complete..."
touch $DATE.test 2> /dev/null
if [ -f "$DATE.test" ]; then
dd_test
@ -95,12 +109,7 @@ else
echo -en "\e[1A"; echo -e "\e[0K\r"
echo -e "You do not have write permission in this directory\nSwitch to a different directory to test disk speed.\nSkipping dd tests."
fi
IPERF_PATH=$YABS_PATH/iperf
mkdir -p $IPERF_PATH
curl -s -o $IPERF_PATH/libiperf.so.0 https://iperf.fr/download/ubuntu/libiperf.so.0_3.1.3 > /dev/null
curl -s -o $IPERF_PATH/iperf3 https://iperf.fr/download/ubuntu/iperf3_3.1.3 > /dev/null
chmod +x $IPERF_PATH/iperf3
fi
function iperf_test {
URL=$1
@ -161,10 +170,17 @@ function launch_iperf {
done
}
if [ -z "$SKIP_IPERF" ]; then
IPERF_PATH=$YABS_PATH/iperf
mkdir -p $IPERF_PATH
curl -s -o $IPERF_PATH/libiperf.so.0 https://iperf.fr/download/ubuntu/libiperf.so.0_3.1.3 > /dev/null
curl -s -o $IPERF_PATH/iperf3 https://iperf.fr/download/ubuntu/iperf3_3.1.3 > /dev/null
chmod +x $IPERF_PATH/iperf3
PING_FLAG=$(man ping | grep -- " -4")
[ -z "$PING_FLAG" ] && IPV4_CHECK=$(ping -c 1 -W 4 google.com) || IPV4_CHECK=$(ping -c 1 -W 4 -4 google.com)
[ -z "$PING_FLAG" ] && IPV4_CHECK=$(ping -c 1 -W 4 google.com 2> /dev/null) || IPV4_CHECK=$(ping -c 1 -W 4 -4 google.com 2> /dev/null)
[[ "$IPV4_CHECK" == *"1 received"* ]] && IPV4_CHECK="True" || IPV4_CHECK=""
[ -z "$PING_FLAG" ] && IPV6_CHECK=$(ping6 -c 1 -W 4 ipv6.google.com) || IPV6_CHECK=$(ping -c 1 -W 4 -6 ipv6.google.com)
[ -z "$PING_FLAG" ] && IPV6_CHECK=$(ping6 -c 1 -W 4 ipv6.google.com 2> /dev/null) || IPV6_CHECK=$(ping -c 1 -W 4 -6 ipv6.google.com 2> /dev/null)
[[ "$IPV6_CHECK" == *"1 received"* ]] && IPV6_CHECK="True" || IPV6_CHECK=""
IPERF_LOCS=( \
@ -186,7 +202,9 @@ IPERF_LOCS_NUM=$((IPERF_LOCS_NUM / 5))
[ -z "$IPv4_CHECK" ] && launch_iperf "IPv4"
[ -z "$IPv6_CHECK" ] && launch_iperf "IPv6"
fi
if [ -z "$SKIP_GEEKBENCH" ]; then
echo -e "Performing Geekbench 4 benchmark test. This may take a couple minutes to complete..."
GEEKBENCH_PATH=$YABS_PATH/geekbench
@ -210,6 +228,7 @@ 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"
[ ! -z "$GEEKBENCH_URL_CLAIM" ] && echo -e "$GEEKBENCH_URL_CLAIM" > geekbench4_claim.url 2> /dev/null
fi
echo -e
rm -rf /tmp/$DATE