1version="1.2" 2umask 022 # at least mortals can read root's files this way 3PWD=`pwd` 4HOMEDIR=${HOMEDIR:-.} 5cd $HOMEDIR 6HOMEDIR=`pwd` 7cd $PWD 8BINDIR=${BINDIR:-${HOMEDIR}/pgms} 9cd $BINDIR 10BINDIR=`pwd` 11cd $PWD 12PATH="${PATH}:${BINDIR}" 13SCRPDIR=${SCRPDIR:-${HOMEDIR}/pgms} 14cd $SCRPDIR 15SCRPDIR=`pwd` 16cd $PWD 17TMPDIR=${HOMEDIR}/tmp 18cd $TMPDIR 19TMPDIR=`pwd` 20cd $PWD 21RESULTDIR=${RESULTDIR:-${HOMEDIR}/results} 22cd $RESULTDIR 23RESULTDIR=`pwd` 24cd $PWD 25TESTDIR=${TESTDIR:-${HOMEDIR}/testdir} 26cd $TESTDIR 27TESTDIR=`pwd` 28cd $PWD 29export BINDIR TMPDIR RESULTDIR PATH 30echo "kill -9 $$" > ${TMPDIR}/kill_run ; chmod u+x ${TMPDIR}/kill_run 31arithmetic="arithoh register short int long float double dc" 32system="syscall pipe context1 spawn execl fstime" 33mem="seqmem randmem" 34misc="C shell" 35dhry="dhry2 dhry2reg" # dhrystone loops 36db="dbmscli" # add to as new database engines are developed 37load="shell" # cummulative load tests 38args="" # the accumulator for the bench units to be run 39runoption="N" 40for word 41do # do level 1 42case $word 43in 44all) 45;; 46arithmetic) 47args="$args $arithmetic" 48;; 49db) 50args="$args $db" 51;; 52dhry) 53args="$args $dhry" 54;; 55load) 56args="$args $load" 57;; 58mem) 59args="$args $mem" 60;; 61misc) 62args="$args $misc" 63;; 64speed) 65args="$args $arithmetic $system" 66;; 67system) 68args="$args $system" 69;; 70-q|-Q) 71runoption="Q" #quiet 72;; 73-v|-V) 74runoption="V" #verbose 75;; 76-d|-D) 77runoption="D" #debug 78;; 79*) 80args="$args $word" 81;; 82esac 83done # end do level 1 84set - $args 85if test $# -eq 0 #no arguments specified 86then 87set - $dhry $arithmetic $system $misc # db and work not included 88fi 89if test "$runoption" = 'D' 90then 91set -x 92set -v 93fi 94date=`date` 95tmp=${TMPDIR}/$$.tmp 96LOGFILE=${RESULTDIR}/log 97if test -w ${RESULTDIR}/log 98then 99if test -w ${RESULTDIR}/log.accum 100then 101cat ${RESULTDIR}/log >> ${RESULTDIR}/log.accum 102rm ${RESULTDIR}/log 103else 104mv ${RESULTDIR}/log ${RESULTDIR}/log.accum 105fi 106echo "Start Benchmark Run (BYTE Version $version)" >>$LOGFILE 107echo " $date (long iterations $iter times)" >>$LOGFILE 108echo " " `who | wc -l` "interactive users." >>$LOGFILE 109uname -a >>$LOGFILE 110iter=${iterations-6} 111if test $iter -eq 6 112then 113longloop="1 2 3 4 5 6" 114shortloop="1 2 3" 115else # generate list of loop numbers 116short=`expr \( $iter + 1 \) / 2` 117longloop="" 118shortloop="" 119while test $iter -gt 0 120do # do level 1 121longloop="$iter $longloop" 122if test $iter -le $short 123then 124shortloop="$iter $shortloop" 125fi 126iter=`expr $iter - 1` 127done # end do level 1 128fi #loop list genration 129for bench # line argument processing 130do # do level 1 131# set some default values 132prog=${BINDIR}/$bench # the bench name is default program 133need=$prog # we need the at least the program 134paramlist="#" # a dummy parameter to make anything run 135testdir="${TESTDIR}" # the directory in which to run the test 136prepcmd="" # preparation command or script 137parammsg="" 138repeat="$longloop" 139stdout="$LOGFILE" 140stdin="" 141cleanopt="-t $tmp" 142bgnumber="" 143trap "${SCRPDIR}/cleanup -l $LOGFILE -a; exit" 1 2 3 15 144if [ $runoption != 'Q' ] 145then 146echo "$bench: \c" 147fi 148echo "" >>$LOGFILE 149###################### select the bench specific values ########## 150case $bench 151in 152dhry2) 153options=${dhryloops-10000} 154logmsg="Dhrystone 2 without register variables" 155cleanopt="-d $tmp" 156;; 157dhry2reg) 158options=${dhryloops-10000} 159logmsg="Dhrystone 2 using register variables" 160cleanopt="-d $tmp" 161;; 162arithoh|register|short|int|long|float|double) 163options=${arithloop-10000} 164logmsg="Arithmetic Test (type = $bench): $options Iterations" 165;; 166dc) need=dc.dat 167prog=dc 168options="" 169stdin=dc.dat 170stdout=/dev/null 171logmsg="Arithmetic Test (sqrt(2) with dc to 99 decimal places)" 172;; 173hanoi) options='$param' 174stdout=/dev/null 175logmsg="Recursion Test: Tower of Hanoi Problem" 176paramlist="${ndisk-17}" 177parammsg='$param Disk Problem:' 178;; 179syscall) 180options=${ncall-4000} 181logmsg="System Call Overhead Test: 5 x $options Calls" 182;; 183context1) 184options=${switch1-500} 185logmsg="Pipe-based Context Switching Test: 2 x $options Switches" 186;; 187pipe) options=${io-2048} 188logmsg="Pipe Throughput Test: read & write $options x 512 byte blocks" 189;; 190spawn) options=${children-100} 191logmsg="Process Creation Test: $options forks" 192;; 193execl) options=${nexecs-100} 194logmsg="Execl Throughput Test: $options execs" 195;; 196randmem|seqmem) 197if test $bench = seqmem 198then 199type=Sequential 200else 201type=Random 202fi 203poke=${poke-1000000} 204options='-s$param '"-n$poke" 205logmsg="$type Memory Access Test: $poke Accesses" 206paramlist=${arrays-"512 1024 2048 8192 16384"} 207parammsg='Array Size: $param bytes' 208cleanopt="-m $tmp" 209;; 210fstime) repeat="$shortloop" 211where=${where-${TMPDIR}} 212options='$param '"$where" 213logmsg="Filesystem Throughput Test:" 214paramlist=${blocks-"512 1024 2048 8192"} 215parammsg='File Size: $param blocks' 216cleanopt="-f $tmp" 217;; 218C) need=cctest.c 219prog=cc 220options='$param' 221stdout=/dev/null 222repeat="$shortloop" 223logmsg="C Compiler Test:" 224paramlist="cctest.c" 225parammsg='cc $param' 226rm -f a.out 227;; 228dbmscli) 229repeat="$shortloop" 230need="db.dat" 231prepcmd='${BINDIR}/dbprep ${testdir}/db.dat 10000' 232paramlist=${clients-"1 2 4 8"} 233parammsg='$param client processes. (filesize `cat ${testdir}/db.dat|wc -c` bytes)' 234logmsg="Client/Server Database Engine:" 235options='${testdir}/db.dat $param 0 1000' # $param clients; 236# 0 sleep; 1000 iterations 237;; 238shell) 239prog="multi.sh" 240repeat="$shortloop" 241logmsg="Bourne shell script and Unix utilities" 242paramlist=${background-"1 2 4 8"} 243parammsg='$param concurrent background processes' 244bgnumber='$param' 245testdir="shelldir" 246;; 247*) ${BINDIR}/cleanup -l $LOGFILE -r "run: unknown benchmark \"$bench\"" -a 248exit 1 249;; 250esac 251echo "$logmsg" >>$LOGFILE 252for param in $paramlist 253do # level 2 254param=`echo $param | sed 's/_/ /g'` # be sure that spaces are used 255# underscore can couple params 256if [ "$runoption" != "Q" ] 257then 258echo "\n [$param] -\c" # generate message to user 259fi 260eval msg='"'$parammsg'"' # the eval is used to 261if test "$msg" # evaluate any embedded 262then # variables in the parammsg 263echo "" >>$LOGFILE 264echo "$msg" >>$LOGFILE 265fi 266eval opt='"'$options'"' # evaluate any vars in options 267eval prep='"'$prepcmd'"' # evaluate any prep command 268eval bg='"'$bgnumber'"' # evaluate bgnumber string 269rm -f $tmp # remove any tmp files 270# if the test requires mulitple concurrent processes, 271# prepare the background process string (bgstr) 272# this is just a string of "+"s that will provides a 273# parameter count for a "for" loop 274bgstr="" 275if test "$bg" != "" 276then 277count=`expr "$bg"` 278while test $count -gt 0 279do 280bgstr="+ $bgstr" 281count=`expr $count - 1` 282done 283fi 284# 285for i in $repeat # loop for the specified number 286do # do depth 3 287if [ "$runoption" != 'D' ] # level 1 288then 289# regular Run - set logfile to go on signal 290trap "${SCRPDIR}/cleanup -l $LOGFILE -i $i $cleanopt -a; exit" 1 2 3 15 291else 292trap "exit" 1 2 3 15 293fi #end level 1 294if [ "$runoption" != 'Q' ] 295then 296echo " $i\c" # display repeat number 297fi 298pwd=`pwd` # remember where we are 299cd $testdir # move to the test directory 300if [ "$runoption" = "V" ] 301then 302echo 303echo "BENCH COMMAND TO BE EXECUTED:" 304echo "$prog $opt" 305fi 306# execute any prepratory command string 307if [ -n "$prep" ] 308then 309$prep >>$stdout 310fi 311############ THE BENCH IS TIMED ############## 312if test "$stdin" = "" 313then # without redirected stdin 314time $prog $opt $bgstr 2>>$tmp >>$stdout 315else # with redirected stdin 316time $prog $opt $bgstr <$stdin 2>>$tmp >>$stdout 317fi 318time $benchcmd 319############################################### 320cd $pwd # move back home 321status=$? # save the result code 322if test $status != 0 # must have been an error 323then 324if test -f $tmp # is there an error file ? 325then 326cp $tmp ${TMPDIR}/save.$bench.$param 327${SCRPDIR}/cleanup -l $LOGFILE -i $i $cleanopt -r \ 328"run: bench=$bench param=$param fatalstatus=$status" -a 329else 330${SCRPDIR}/cleanup -l $LOGFILE -r \ 331"run: bench=$bench param=$param fatalstatus=$status" -a 332fi 333exit # leave the script if there are errors 334fi # end level 1 335done # end do depth 3 - repeat of bench 336if [ "$runoption" != 'D' ] 337then 338${SCRPDIR}/cleanup -l $LOGFILE $cleanopt # finalize this bench 339# with these options 340# & calculate results 341fi 342done # end do depth 2 - end of all options for this bench 343########### some specific cleanup routines ############## 344case $bench 345in 346C) 347rm -f cctest.o a.out 348;; 349esac 350if [ "$runoption" != 'Q' ] 351then 352echo "" 353fi 354done # end do level 1 - all benchmarks requested 355echo "" >>$LOGFILE 356echo " " `who | wc -l` "interactive users." >>$LOGFILE 357echo "End Benchmark Run ($date) ...." >>$LOGFILE 358if [ "$runoption" != 'Q' ] 359then 360pg $LOGFILE 361fi 362exit 363