2015-01-20 16:17:32 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
dir=/tmp
|
|
|
|
filesize=100 # megabytes
|
|
|
|
numfiles=128
|
|
|
|
nocache=
|
|
|
|
interleave=
|
|
|
|
needfiles=1
|
2015-01-22 11:27:49 -05:00
|
|
|
write_blocksize=262144
|
2015-01-20 16:17:32 -05:00
|
|
|
|
2015-01-20 17:19:23 -05:00
|
|
|
if uname -a | grep --silent arwin ; then
|
|
|
|
ddmega=m
|
|
|
|
else
|
|
|
|
ddmega=M
|
|
|
|
fi
|
2015-01-20 16:17:32 -05:00
|
|
|
|
|
|
|
while [ $# -gt 1 ] ; do
|
|
|
|
case $1 in
|
|
|
|
-d) dir=$2; shift; shift ;;
|
|
|
|
-f) filesize=$2; shift; shift ;;
|
|
|
|
-n) numfiles=$2; shift; shift ;;
|
2015-01-23 12:24:53 -05:00
|
|
|
-N) nocache="-s"; shift;;
|
2015-01-22 11:27:49 -05:00
|
|
|
*) break ;;
|
2015-01-20 16:17:32 -05:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -d $dir -a -f $dir/testfile_1 ] ; then
|
|
|
|
# dir exists and has a testfile within it - reuse to avoid
|
|
|
|
# recreating files
|
|
|
|
echo "Re-using files in $dir"
|
|
|
|
needfiles=
|
|
|
|
else
|
|
|
|
dir=$dir/readtest_$$
|
|
|
|
mkdir $dir
|
|
|
|
|
|
|
|
if [ $? != 0 ] ; then
|
|
|
|
echo "Cannot create testfile directory $dir"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ x$needfiles != x ] ; then
|
2015-01-22 11:27:49 -05:00
|
|
|
echo "Building files for test..."
|
2015-01-20 16:17:32 -05:00
|
|
|
if [ x$interleave = x ] ; then
|
|
|
|
|
|
|
|
#
|
|
|
|
# Create all files sequentially
|
|
|
|
#
|
|
|
|
|
|
|
|
for i in `seq 1 $numfiles` ; do
|
2015-01-22 11:27:49 -05:00
|
|
|
dd of=$dir/testfile_$i if=/dev/zero bs=1$ddmega count=$filesize >/dev/null 2>&1
|
2015-01-20 16:17:32 -05:00
|
|
|
done
|
|
|
|
else
|
|
|
|
|
|
|
|
#
|
2015-01-22 11:27:49 -05:00
|
|
|
# Create files interleaved, adding $write_blocksize to each
|
2015-01-20 16:17:32 -05:00
|
|
|
# file in turn.
|
|
|
|
#
|
|
|
|
|
|
|
|
size=0
|
|
|
|
limit=`expr $filesize * 1048576`
|
|
|
|
while [ $size -lt $limit ] ; do
|
|
|
|
for i in `seq 1 $numfiles` ; do
|
2015-01-22 12:15:39 -05:00
|
|
|
dd if=/dev/zero bs=$write_blocksize count=1 >> $dir/testfile_$i 2>/dev/null
|
2015-01-20 16:17:32 -05:00
|
|
|
done
|
2015-01-22 11:27:49 -05:00
|
|
|
size=`expr $size + $write_blocksize`
|
2015-01-20 16:17:32 -05:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-01-22 11:27:49 -05:00
|
|
|
for bs in $@ ; do
|
2015-01-20 16:17:32 -05:00
|
|
|
|
2015-01-22 11:27:49 -05:00
|
|
|
if uname -a | grep --silent arwin ; then
|
|
|
|
# clears cache on OS X
|
|
|
|
sudo purge
|
2015-01-22 12:21:15 -05:00
|
|
|
elif [ -f /proc/sys/vm/drop_caches ] ; then
|
2015-01-22 11:27:49 -05:00
|
|
|
# Linux cache clearing
|
2015-01-22 12:15:39 -05:00
|
|
|
echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
|
2015-01-22 11:27:49 -05:00
|
|
|
else
|
|
|
|
# need an alternative for other operating systems
|
|
|
|
:
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Blocksize $bs"
|
|
|
|
./readtest $nocache -b $bs -q $dir/testfile_%d
|
|
|
|
done
|