Increase editable region alpha slightly.
[ardour.git] / tools / run-readtest.sh
1 #!/bin/sh
2
3 dir=/tmp
4 filesize=100 # megabytes
5 numfiles=128
6 nocache=
7 interleave=
8 needfiles=1
9 write_blocksize=262144
10
11 if uname -a | grep --silent arwin ; then
12     ddmega=m
13 else
14     ddmega=M
15 fi
16
17 while [ $# -gt 1 ] ; do
18     case $1 in
19         -d) dir=$2; shift; shift ;;
20         -f) filesize=$2; shift; shift ;;
21         -n) numfiles=$2; shift; shift ;;
22         *) break ;;
23     esac
24 done
25
26 if [ -d $dir -a -f $dir/testfile_1 ] ; then
27     # dir exists and has a testfile within it - reuse to avoid
28     # recreating files
29     echo "# Re-using files in $dir"
30     needfiles=
31 else
32     dir=$dir/readtest_$$
33     mkdir $dir
34     
35     if [ $? != 0 ] ; then
36         echo "Cannot create testfile directory $dir"
37         exit 1
38     fi
39 fi
40
41 if [ x$needfiles != x ] ; then
42     echo "# Building files for test..."
43     if [ x$interleave = x ] ; then
44         
45         #
46         # Create all files sequentially
47         #
48         
49         for i in `seq 1 $numfiles` ; do
50             dd of=$dir/testfile_$i if=/dev/zero bs=1$ddmega count=$filesize >/dev/null 2>&1
51         done
52     else
53         
54         #
55         # Create files interleaved, adding $write_blocksize to each
56         # file in turn.
57         #
58         
59         size=0
60         limit=`expr $filesize * 1048576`
61         while [ $size -lt $limit ] ; do
62             for i in `seq 1 $numfiles` ; do
63                 dd if=/dev/zero bs=$write_blocksize count=1 >> $dir/testfile_$i 2>/dev/null
64             done
65             size=`expr $size + $write_blocksize`
66         done
67     fi
68 fi
69
70 for bs in $@ ; do
71
72     if uname -a | grep --silent arwin ; then
73         # clears cache on OS X
74         sudo purge
75     elif [ -f /proc/sys/vm/drop_caches ] ; then
76         # Linux cache clearing
77         echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
78     else       
79         # need an alternative for other operating systems
80         :
81     fi
82     
83     echo "# Blocksize $bs"
84     ./readtest -b $bs -q $dir/testfile_%d
85 done