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;;
*) 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
2015-01-28 08:35:17 -05:00
echo "# Re-using files in $dir"
2015-01-20 16:17:32 -05:00
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-28 08:35:17 -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
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 2>/dev/null
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
2015-01-22 12:21:15 -05:00
elif [ -f /proc/sys/vm/drop_caches ] ; then
# Linux cache clearing
echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
else
# need an alternative for other operating systems
:
fi
2015-01-28 08:35:17 -05:00
echo "# Blocksize $bs"
./readtest $nocache -b $bs -q $dir/testfile_%d
done