Jacks program for testing multiple concurrent reader scalability.
[xfstests-dev.git] / src / scaleread.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2003-2004 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of version 2 of the GNU General Public License as
7 # published by the Free Software Foundation.
8 #
9 # This program is distributed in the hope that it would be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 #
13 # Further, this software is distributed without any warranty that it is
14 # free of the rightful claim of any third person regarding infringement
15 # or the like.  Any license provided herein, whether implied or
16 # otherwise, applies only to this software file.  Patent licenses, if
17 # any, provided herein do not apply to combinations of this program with
18 # other software, or any other product whatsoever.
19 #
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write the Free Software Foundation, Inc., 59
22 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 #
24 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 # Mountain View, CA  94043, or:
26 #
27 # http://www.sgi.com
28 #
29 # For further information regarding this notice, see:
30 #
31 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #
33
34 help() {
35 cat <<END
36 Measure scaling of multiple cpus readin the same set of files.
37 (NASA testcase).
38         Usage:  $0 [-b <bytes>] [-f <files>] [-s] [-B] [-v] cpus ...
39                         or
40                 $0 -i [-b <bytes>] [-f <files>] 
41
42           -b file size in bytes
43           -f number of files
44           -s keep processes synchronized when reading files
45           -B use bcfree to free buffer cache pages before each run
46 END
47 exit 1
48 }
49
50 err () {
51         echo "ERROR - $*"
52         exit 1
53 }
54
55 BYTES=8192
56 FILES=10
57 SYNC=""
58 VERBOSE=""
59 STRIDED=""
60 BCFREE=0
61 INIT=0
62 OPTS="f:b:vsiSBH"
63 while getopts "$OPTS" c ; do
64         case $c in
65                 H)  help;;
66                 f)  FILES=${OPTARG};;
67                 b)  BYTES=${OPTARG};;
68                 i)  INIT=1;;
69                 B)  BCFREE=1;;
70                 S)  STRIDED="-S";;
71                 s)  SYNC="-s";;
72                 v)  VERBOSE="-v";;
73                 \?) help;;
74         esac
75
76 done
77 shift `expr $OPTIND - 1`
78
79 if [ $INIT -gt 0 ] ; then
80         echo "Initializing $BYTES bytes, $FILES files"
81         ./scaleread $VERBOSE -i -b $BYTES -f $FILES 
82         sync
83 else
84         [ $# -gt 0 ] || help
85         echo "Testing $BYTES bytes, $FILES files"
86         for CPUS in $* ; do
87                 [ $BCFREE -eq 0 ] || bcfree -a
88                 /usr/bin/time -f "$CPUS:  %e wall,    %S sys,   %U user" ./scaleread \
89                         $SYNC $STRIDED $VERBOSE -b $BYTES -f $FILES -c $CPUS
90         done
91 fi
92