13
0
livetrax/tools/run-readtest.sh

87 lines
1.7 KiB
Bash
Raw Normal View History

2015-01-20 16:17:32 -05:00
#!/bin/sh
dir=/tmp
filesize=100 # megabytes
numfiles=128
nocache=
interleave=
needfiles=1
write_blocksize=262144
2015-01-20 16:17:32 -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 ;;
-N) nocache="-s"; shift; shift ;;
*) 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
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
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
#
# 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
dd if=/dev/zero bs=$write_blocksize count=1 >> $dir/testfile_$i >/dev/null 2>&1
2015-01-20 16:17:32 -05:00
done
size=`expr $size + $write_blocksize`
2015-01-20 16:17:32 -05:00
done
fi
fi
for bs in $@ ; do
2015-01-20 16:17:32 -05:00
if uname -a | grep --silent arwin ; then
# clears cache on OS X
sudo purge
elif [ -f /proc/sys/vm/drop_cache ] ; then
# Linux cache clearing
echo 3 | sudo tee /proc/sys/vm/drop/cache >/dev/null
else
# need an alternative for other operating systems
:
fi
echo "Blocksize $bs"
./readtest $nocache -b $bs -q $dir/testfile_%d
done