Added command-line option -w.
authorbvassche <bvassche@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Fri, 6 Nov 2009 13:17:14 +0000 (13:17 +0000)
committerbvassche <bvassche@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Fri, 6 Nov 2009 13:17:14 +0000 (13:17 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@1321 d57e44dd-8a1f-0410-8b47-8ef2f437770f

scripts/blockdev-perftest

index f8bfa00..77a6ec9 100755 (executable)
@@ -39,6 +39,7 @@ usage() {
   echo "        -r - only perform the read test."
   echo "        -s - logarithm base two of the I/O size."
   echo "        -t - username and hostname of the target to drop the caches on."
+  echo "        -w - only perform the write test."
   echo "        <dev> - block device to run the I/O performance test on."
 }
 
@@ -130,7 +131,8 @@ log2_io_size=30       # 1 GB
 log2_min_blocksize=9  # 512 bytes
 log2_max_blocksize=26 # 64 MB
 iotype=direct
-read_test_only=false
+perform_read_test=true
+perform_write_test=true
 target_login=""
 use_fio=false
 verify_device_data=true
@@ -140,7 +142,7 @@ verify_device_data=true
 # Argument processing   #
 #########################
 
-set -- $(/usr/bin/getopt "adfhi:jm:M:nrs:t:" "$@")
+set -- $(/usr/bin/getopt "adfhi:jm:M:nrs:t:w" "$@")
 while [ "$1" != "${1#-}" ]
 do
   case "$1" in
@@ -152,9 +154,10 @@ do
     '-m') log2_min_blocksize="$2"; shift; shift;;
     '-M') log2_max_blocksize="$2"; shift; shift;;
     '-n') verify_device_data="false"; shift;;
-    '-r') read_test_only="true"; shift;;
+    '-r') perform_write_test="false"; shift;;
     '-s') log2_io_size="$2"; shift; shift;;
     '-t') target_login="$2"; shift; shift;;
+    '-w') perform_read_test="false"; shift;;
     '--') shift;;
     *)    usage; exit 1;;
   esac
@@ -177,19 +180,20 @@ if [ ! -e "${device}" ]; then
   exit 1
 fi
 
-if [ "${read_test_only}" = "false" -a ! -w "${device}" ]; then
+if [ "${perform_write_test}" = "true" -a ! -w "${device}" ]; then
   echo "Error: device ${device} is not writeable."
   exit 1
 fi
 
-if [ $(dd if="${device}" bs=1M count=$(pow2 $(($log2_io_size - 20))) \
+if [ "${perform_read_test}" = "true" -a                              \
+     $(dd if="${device}" bs=1M count=$(pow2 $(($log2_io_size - 20))) \
      2>/dev/null | wc --bytes) -lt $(pow2 $log2_io_size) ]
 then
   echo "Error: device ${device} contains less than $(pow2 $log2_io_size) bytes."
   exit 1
 fi
 
-if [ "${read_test_only}" = "false" -a "${verify_device_data}" = "true" ] \
+if [ "${perform_write_test}" = "true" -a "${verify_device_data}" = "true" ] \
    && [ "${force}" != "true" ] \
    && ! cmp -s -n $(pow2 $log2_io_size) "${device}" /dev/zero
 then
@@ -255,7 +259,7 @@ do
   i=0
   while [ $i -lt ${iterations} ]
   do
-    if [ "${read_test_only}" = "false" ]; then
+    if [ "${perform_write_test}" = "true" ]; then
       time_write ${bs} ${count}
     else
       echo " 0 s,"
@@ -266,7 +270,11 @@ do
   i=0
   while [ $i -lt ${iterations} ]
   do
-    time_read ${bs} ${count}
+    if [ "${perform_read_test}" = "true" ]; then
+      time_read ${bs} ${count}
+    else
+      echo " 0 s,"
+    fi
     i=$((i+1))
   done | echo_and_calc_avg "%8.3f " ${iosize} ${bs}
   printf "\n"