#!/bin/ksh # This script will test disk performance by writing a large file (default=10GB), # reading it, copying it, and comparing the copies. # It uses 6 different block sizes: 128KB, 64KB, 32KB, 16KB, 8KB, 4KB size=$1 size=${size:-10} bytes=$(expr 1024 \* 1024 \* 1024 \* $size) file1=/diamond/test00/file1 file2=/diamond/test01/file2 echo "Test of disk performance for $(hostname) started: $(date)\nUsing file size of $size GB ($bytes bytes)" for blocksize in 131072 65536 32768 16384 8192 4096 do count=$(expr $bytes / $blocksize) echo "\nTesting with $count blocks of $(expr $blocksize / 1024) KB ($blocksize bytes) each..." echo "Writing file..." writetime=$(timex dd if=/dev/zero of=$file1 bs=$blocksize count=$count 2>&1 | grep real | cut -f 2 -d " " | cut -f 1 -d ".") writerate=$(expr $bytes / $writetime / 1024 / 1024) echo "Wrote $bytes bytes in $writetime seconds = $writerate MB/s" echo "Reading file..." readtime=$(timex dd if=$file1 of=/dev/null bs=$blocksize count=$count 2>&1 | grep real | cut -f 2 -d " " | cut -f 1 -d ".") readrate=$(expr $bytes / $readtime / 1024 / 1024) echo "Read $bytes bytes in $readtime seconds = $readrate MB/s" echo "Copying file..." copytime=$(timex dd if=$file1 of=$file2 bs=$blocksize count=$count 2>&1 | grep real | cut -f 2 -d " " | cut -f 1 -d ".") copyrate=$(expr $bytes / $copytime / 1024 / 1024) echo "Copied $bytes bytes in $copytime seconds = $copyrate MB/s" echo "Comparing files..." comparetime=$(timex diff $file1 $file2 2>&1 | grep real | cut -f 2 -d " " | cut -f 1 -d ".") comparerate=$(expr $bytes / $comparetime / 1024 / 1024) echo "Compared $bytes bytes in $comparetime seconds = $comparerate MB/s" rm -f $file1 $file2 done echo "\nTest of disk performance for $(hostname) completed: $(date)"