polishing speedtest

This commit is contained in:
ville rantanen
2021-12-18 15:12:55 +02:00
parent 3ff41671ba
commit 743d6946b8

View File

@@ -4,7 +4,7 @@ _help() {
echo ' echo '
SSH performance test SSH performance test
args: [-s size] [-r repeats] [-t timeout] [-d/-u] user@host args: [-s size] [-r repeats] [-t timeout] [-d/-u] [--no-color] user@host
Options: Options:
@@ -13,6 +13,7 @@ Options:
-t timeout: default: 60 -t timeout: default: 60
-d Download only -d Download only
-u Upload only -u Upload only
--no-color No Color
' '
exit exit
} }
@@ -36,13 +37,18 @@ _size_in_bytes() {
} }
_msg() { _msg() {
echo ""
echo "$1 $size repeated $repeats times, timeout ${timeout}s:" echo "$1 $size repeated $repeats times, timeout ${timeout}s:"
echo "Size Time [Speed] [Average] [Progress]"
echo -e $YELLOW"$1"
} }
size=100MB size=100MB
repeats=1 repeats=1
upload=1 upload=1
download=1 download=1
timeout=60 timeout=60
YELLOW="\033[1;33m"
NORMAL="\033[0m"
shift_arg=0 shift_arg=0
for (( i=1; i<=$#; i++ )); do for (( i=1; i<=$#; i++ )); do
@@ -60,6 +66,7 @@ for (( i=1; i<=$#; i++ )); do
[[ "$value" = -u ]] && { download=0; continue; } [[ "$value" = -u ]] && { download=0; continue; }
[[ "$value" = -d ]] && { upload=0; continue; } [[ "$value" = -d ]] && { upload=0; continue; }
[[ "$value" = -t ]] && { timeout=${!j}; } [[ "$value" = -t ]] && { timeout=${!j}; }
[[ "$value" = --no-color ]] && { NORMAL=""; YELLOW=""; continue; }
shift_arg=1 shift_arg=1
continue continue
else else
@@ -78,14 +85,17 @@ if [[ $download -eq 1 ]]; then
_msg "Downloading" _msg "Downloading"
for i in $( seq $repeats ); do for i in $( seq $repeats ); do
timeout $timeout ssh -o 'Compression no' "$host" "dd if=/dev/zero bs=$onemb count=$megabytes 2>/dev/null" | \ timeout $timeout ssh -o 'Compression no' "$host" "dd if=/dev/zero bs=$onemb count=$megabytes 2>/dev/null" | \
pv -W -f -s ${bytes} > /dev/null pv -W -f -paterb -s ${bytes} > /dev/null
done done
echo -en $NORMAL
fi fi
if [[ $upload -eq 1 ]]; then if [[ $upload -eq 1 ]]; then
_msg "Uploading" _msg "Uploading"
for i in $( seq $repeats ); do for i in $( seq $repeats ); do
cols=$( tput cols )
timeout $timeout dd if=/dev/zero bs=$onemb count=$megabytes 2>/dev/null | \ timeout $timeout dd if=/dev/zero bs=$onemb count=$megabytes 2>/dev/null | \
ssh -o 'Compression no' "$host" "cat | pv -W -f -s ${bytes} > /dev/null" ssh -o 'Compression no' "$host" "cat | pv -W -f -paterb -w ${cols} -s ${bytes} > /dev/null"
done done
echo -en $NORMAL
fi fi