# cat 1gb-ide-bench 
#!/bin/sh

#written by David Ranch - dranch@trinnet.net

#Create 1GB files via different dd BS sizes
# 02/25/03

I=0
BS="1 2 4 8 16 32 64 128"

#FW devices
#DEVICE=/dev/sda1

#IDE devices
DEVICE=/dev/hdc1


#reset results file
date > 1gb-test-bs.results


echo -e "\n`uname -a`" >> 1gb-test-bs.results
echo -e "\n`mount`" >> 1gb-test-bs.results
echo -e "------------------------------------------------------------------" \
>> 1gb-test-bs.results
echo -e "------------------------------------------------------------------\n" \
>> 1gb-test-bs.results

echo -e "\nRunning HDparm -T on $DEVICE\n" 
echo -e "Running HDparm -T on $DEVICE" >> 1gb-test-bs.results
hdparm -T $DEVICE >> 1gb-test-bs.results

echo -e "------------------------------------------------------------------" \
>> 1gb-test-bs.results


for I in $BS; do
  echo -e "\nRemoving old 1gb-dd file\n"
  rm -f /mnt/disk/1gb-dd-file
  #echo "I: $I"
  #Multiplier is 1024 via the use of k
  COUNT=$((1024000/$I))
  echo -en "Executing 1gb test with BS of $I k ... "
  echo -e "Executing 1gb test with BS of $I k\n" >> 1gb-test-bs.results
  time dd if=/dev/zero of=/mnt/disk/1gb-dd-file bs=`echo $I`k count=$COUNT \
    2>> 1gb-test-bs.results >> 1gb-test-bs.results
  echo -e "\n`ls -la /mnt/disk/1gb-dd-file`" >> 1gb-test-bs.results
  echo -e "------------------------------------------------------------------" \
  >> 1gb-test-bs.results
done

echo -e "\n------------------------------------------------------------------" \
>> 1gb-test-bs.results

echo -e "\n\nExecuting 1gb READ test\n"
echo -e "\nExecuting 1gb READ test\n" >> 1gb-test-bs.results
echo -e "\n`ls -la /mnt/disk/1gb-dd-file`" >> 1gb-test-bs.results
time cat /mnt/disk/1gb-dd-file > /dev/null 2>> 1gb-test-bs.results

echo -e "\nRemoving old 1gb-dd file\n"
rm -f /mnt/disk/1gb-dd-file

echo -e "\n------------------------------------------------------------------" \
>> 1gb-test-bs.results

echo -e "Running Bonnie++"
#make sure the perms are ok
chmod 777 /mnt/disk
/usr/local/sbin/bonnie++ -d /mnt/disk -s 760 -u dranch >> 1gb-test-bs.results

echo -e "\ndone.\n\n" 
echo -e "\ndone.\n\n" >> 1gb-test-bs.results
