From 1050224c169c3277e8cf247380aa93aa3f906c2d Mon Sep 17 00:00:00 2001 From: Seamile Date: Wed, 17 Apr 2024 16:14:22 +0800 Subject: [PATCH] Fixed function io_test adapt to the Chinese environment (#124) --- bench.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bench.sh b/bench.sh index 7dfc56f..7e88716 100644 --- a/bench.sh +++ b/bench.sh @@ -57,7 +57,7 @@ next() { speed_test() { local nodeName="$2" - if [ -z "$1" ];then + if [ -z "$1" ];then ./speedtest-cli/speedtest --progress=no --accept-license --accept-gdpr >./speedtest-cli/speedtest.log 2>&1 else ./speedtest-cli/speedtest --progress=no --server-id="$1" --accept-license --accept-gdpr >./speedtest-cli/speedtest.log 2>&1 @@ -90,7 +90,7 @@ speed() { } io_test() { - (LANG=C dd if=/dev/zero of=benchtest_$$ bs=512k count="$1" conv=fdatasync && rm -f benchtest_$$) 2>&1 | awk -F, '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' + (LANG=C dd if=/dev/zero of=benchtest_$$ bs=512k count="$1" conv=fdatasync && rm -f benchtest_$$) 2>&1 | awk -F '[,,]' '{io=$NF} END { print io}' | sed 's/^[ \t]*//;s/[ \t]*$//' } calc_size() { @@ -373,11 +373,11 @@ print_io_test() { io3=$(io_test ${writemb}) echo " I/O Speed(3rd run) : $(_yellow "$io3")" ioraw1=$(echo "$io1" | awk 'NR==1 {print $1}') - [ "$(echo "$io1" | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw1=$(awk 'BEGIN{print '"$ioraw1"' * 1024}') + [[ "$(echo "$io1" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw1=$(awk 'BEGIN{print '"$ioraw1"' * 1024}') ioraw2=$(echo "$io2" | awk 'NR==1 {print $1}') - [ "$(echo "$io2" | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw2=$(awk 'BEGIN{print '"$ioraw2"' * 1024}') + [[ "$(echo "$io2" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw2=$(awk 'BEGIN{print '"$ioraw2"' * 1024}') ioraw3=$(echo "$io3" | awk 'NR==1 {print $1}') - [ "$(echo "$io3" | awk 'NR==1 {print $2}')" == "GB/s" ] && ioraw3=$(awk 'BEGIN{print '"$ioraw3"' * 1024}') + [[ "$(echo "$io3" | awk 'NR==1 {print $2}')" == "GB/s" ]] && ioraw3=$(awk 'BEGIN{print '"$ioraw3"' * 1024}') ioall=$(awk 'BEGIN{print '"$ioraw1"' + '"$ioraw2"' + '"$ioraw3"'}') ioavg=$(awk 'BEGIN{printf "%.1f", '"$ioall"' / 3}') echo " I/O Speed(average) : $(_yellow "$ioavg MB/s")"