polishing speedtest
This commit is contained in:
@@ -4,7 +4,7 @@ _help() {
|
||||
echo '
|
||||
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:
|
||||
|
||||
@@ -13,6 +13,7 @@ Options:
|
||||
-t timeout: default: 60
|
||||
-d Download only
|
||||
-u Upload only
|
||||
--no-color No Color
|
||||
'
|
||||
exit
|
||||
}
|
||||
@@ -36,13 +37,18 @@ _size_in_bytes() {
|
||||
|
||||
}
|
||||
_msg() {
|
||||
echo ""
|
||||
echo "$1 $size repeated $repeats times, timeout ${timeout}s:"
|
||||
echo "Size Time [Speed] [Average] [Progress]"
|
||||
echo -e $YELLOW"$1"
|
||||
}
|
||||
size=100MB
|
||||
repeats=1
|
||||
upload=1
|
||||
download=1
|
||||
timeout=60
|
||||
YELLOW="\033[1;33m"
|
||||
NORMAL="\033[0m"
|
||||
|
||||
shift_arg=0
|
||||
for (( i=1; i<=$#; i++ )); do
|
||||
@@ -60,6 +66,7 @@ for (( i=1; i<=$#; i++ )); do
|
||||
[[ "$value" = -u ]] && { download=0; continue; }
|
||||
[[ "$value" = -d ]] && { upload=0; continue; }
|
||||
[[ "$value" = -t ]] && { timeout=${!j}; }
|
||||
[[ "$value" = --no-color ]] && { NORMAL=""; YELLOW=""; continue; }
|
||||
shift_arg=1
|
||||
continue
|
||||
else
|
||||
@@ -78,14 +85,17 @@ if [[ $download -eq 1 ]]; then
|
||||
_msg "Downloading"
|
||||
for i in $( seq $repeats ); do
|
||||
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
|
||||
echo -en $NORMAL
|
||||
fi
|
||||
if [[ $upload -eq 1 ]]; then
|
||||
_msg "Uploading"
|
||||
for i in $( seq $repeats ); do
|
||||
cols=$( tput cols )
|
||||
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
|
||||
echo -en $NORMAL
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user