minix/benchmarks/unixbench-5.1.2/testdir/sort.src

363 lines
8.3 KiB
Text
Raw Normal View History

version="1.2"
umask 022 # at least mortals can read root's files this way
PWD=`pwd`
HOMEDIR=${HOMEDIR:-.}
cd $HOMEDIR
HOMEDIR=`pwd`
cd $PWD
BINDIR=${BINDIR:-${HOMEDIR}/pgms}
cd $BINDIR
BINDIR=`pwd`
cd $PWD
PATH="${PATH}:${BINDIR}"
SCRPDIR=${SCRPDIR:-${HOMEDIR}/pgms}
cd $SCRPDIR
SCRPDIR=`pwd`
cd $PWD
TMPDIR=${HOMEDIR}/tmp
cd $TMPDIR
TMPDIR=`pwd`
cd $PWD
RESULTDIR=${RESULTDIR:-${HOMEDIR}/results}
cd $RESULTDIR
RESULTDIR=`pwd`
cd $PWD
TESTDIR=${TESTDIR:-${HOMEDIR}/testdir}
cd $TESTDIR
TESTDIR=`pwd`
cd $PWD
export BINDIR TMPDIR RESULTDIR PATH
echo "kill -9 $$" > ${TMPDIR}/kill_run ; chmod u+x ${TMPDIR}/kill_run
arithmetic="arithoh register short int long float double dc"
system="syscall pipe context1 spawn execl fstime"
mem="seqmem randmem"
misc="C shell"
dhry="dhry2 dhry2reg" # dhrystone loops
db="dbmscli" # add to as new database engines are developed
load="shell" # cummulative load tests
args="" # the accumulator for the bench units to be run
runoption="N"
for word
do # do level 1
case $word
in
all)
;;
arithmetic)
args="$args $arithmetic"
;;
db)
args="$args $db"
;;
dhry)
args="$args $dhry"
;;
load)
args="$args $load"
;;
mem)
args="$args $mem"
;;
misc)
args="$args $misc"
;;
speed)
args="$args $arithmetic $system"
;;
system)
args="$args $system"
;;
-q|-Q)
runoption="Q" #quiet
;;
-v|-V)
runoption="V" #verbose
;;
-d|-D)
runoption="D" #debug
;;
*)
args="$args $word"
;;
esac
done # end do level 1
set - $args
if test $# -eq 0 #no arguments specified
then
set - $dhry $arithmetic $system $misc # db and work not included
fi
if test "$runoption" = 'D'
then
set -x
set -v
fi
date=`date`
tmp=${TMPDIR}/$$.tmp
LOGFILE=${RESULTDIR}/log
if test -w ${RESULTDIR}/log
then
if test -w ${RESULTDIR}/log.accum
then
cat ${RESULTDIR}/log >> ${RESULTDIR}/log.accum
rm ${RESULTDIR}/log
else
mv ${RESULTDIR}/log ${RESULTDIR}/log.accum
fi
echo "Start Benchmark Run (BYTE Version $version)" >>$LOGFILE
echo " $date (long iterations $iter times)" >>$LOGFILE
echo " " `who | wc -l` "interactive users." >>$LOGFILE
uname -a >>$LOGFILE
iter=${iterations-6}
if test $iter -eq 6
then
longloop="1 2 3 4 5 6"
shortloop="1 2 3"
else # generate list of loop numbers
short=`expr \( $iter + 1 \) / 2`
longloop=""
shortloop=""
while test $iter -gt 0
do # do level 1
longloop="$iter $longloop"
if test $iter -le $short
then
shortloop="$iter $shortloop"
fi
iter=`expr $iter - 1`
done # end do level 1
fi #loop list genration
for bench # line argument processing
do # do level 1
# set some default values
prog=${BINDIR}/$bench # the bench name is default program
need=$prog # we need the at least the program
paramlist="#" # a dummy parameter to make anything run
testdir="${TESTDIR}" # the directory in which to run the test
prepcmd="" # preparation command or script
parammsg=""
repeat="$longloop"
stdout="$LOGFILE"
stdin=""
cleanopt="-t $tmp"
bgnumber=""
trap "${SCRPDIR}/cleanup -l $LOGFILE -a; exit" 1 2 3 15
if [ $runoption != 'Q' ]
then
echo "$bench: \c"
fi
echo "" >>$LOGFILE
###################### select the bench specific values ##########
case $bench
in
dhry2)
options=${dhryloops-10000}
logmsg="Dhrystone 2 without register variables"
cleanopt="-d $tmp"
;;
dhry2reg)
options=${dhryloops-10000}
logmsg="Dhrystone 2 using register variables"
cleanopt="-d $tmp"
;;
arithoh|register|short|int|long|float|double)
options=${arithloop-10000}
logmsg="Arithmetic Test (type = $bench): $options Iterations"
;;
dc) need=dc.dat
prog=dc
options=""
stdin=dc.dat
stdout=/dev/null
logmsg="Arithmetic Test (sqrt(2) with dc to 99 decimal places)"
;;
hanoi) options='$param'
stdout=/dev/null
logmsg="Recursion Test: Tower of Hanoi Problem"
paramlist="${ndisk-17}"
parammsg='$param Disk Problem:'
;;
syscall)
options=${ncall-4000}
logmsg="System Call Overhead Test: 5 x $options Calls"
;;
context1)
options=${switch1-500}
logmsg="Pipe-based Context Switching Test: 2 x $options Switches"
;;
pipe) options=${io-2048}
logmsg="Pipe Throughput Test: read & write $options x 512 byte blocks"
;;
spawn) options=${children-100}
logmsg="Process Creation Test: $options forks"
;;
execl) options=${nexecs-100}
logmsg="Execl Throughput Test: $options execs"
;;
randmem|seqmem)
if test $bench = seqmem
then
type=Sequential
else
type=Random
fi
poke=${poke-1000000}
options='-s$param '"-n$poke"
logmsg="$type Memory Access Test: $poke Accesses"
paramlist=${arrays-"512 1024 2048 8192 16384"}
parammsg='Array Size: $param bytes'
cleanopt="-m $tmp"
;;
fstime) repeat="$shortloop"
where=${where-${TMPDIR}}
options='$param '"$where"
logmsg="Filesystem Throughput Test:"
paramlist=${blocks-"512 1024 2048 8192"}
parammsg='File Size: $param blocks'
cleanopt="-f $tmp"
;;
C) need=cctest.c
prog=cc
options='$param'
stdout=/dev/null
repeat="$shortloop"
logmsg="C Compiler Test:"
paramlist="cctest.c"
parammsg='cc $param'
rm -f a.out
;;
dbmscli)
repeat="$shortloop"
need="db.dat"
prepcmd='${BINDIR}/dbprep ${testdir}/db.dat 10000'
paramlist=${clients-"1 2 4 8"}
parammsg='$param client processes. (filesize `cat ${testdir}/db.dat|wc -c` bytes)'
logmsg="Client/Server Database Engine:"
options='${testdir}/db.dat $param 0 1000' # $param clients;
# 0 sleep; 1000 iterations
;;
shell)
prog="multi.sh"
repeat="$shortloop"
logmsg="Bourne shell script and Unix utilities"
paramlist=${background-"1 2 4 8"}
parammsg='$param concurrent background processes'
bgnumber='$param'
testdir="shelldir"
;;
*) ${BINDIR}/cleanup -l $LOGFILE -r "run: unknown benchmark \"$bench\"" -a
exit 1
;;
esac
echo "$logmsg" >>$LOGFILE
for param in $paramlist
do # level 2
param=`echo $param | sed 's/_/ /g'` # be sure that spaces are used
# underscore can couple params
if [ "$runoption" != "Q" ]
then
echo "\n [$param] -\c" # generate message to user
fi
eval msg='"'$parammsg'"' # the eval is used to
if test "$msg" # evaluate any embedded
then # variables in the parammsg
echo "" >>$LOGFILE
echo "$msg" >>$LOGFILE
fi
eval opt='"'$options'"' # evaluate any vars in options
eval prep='"'$prepcmd'"' # evaluate any prep command
eval bg='"'$bgnumber'"' # evaluate bgnumber string
rm -f $tmp # remove any tmp files
# if the test requires mulitple concurrent processes,
# prepare the background process string (bgstr)
# this is just a string of "+"s that will provides a
# parameter count for a "for" loop
bgstr=""
if test "$bg" != ""
then
count=`expr "$bg"`
while test $count -gt 0
do
bgstr="+ $bgstr"
count=`expr $count - 1`
done
fi
#
for i in $repeat # loop for the specified number
do # do depth 3
if [ "$runoption" != 'D' ] # level 1
then
# regular Run - set logfile to go on signal
trap "${SCRPDIR}/cleanup -l $LOGFILE -i $i $cleanopt -a; exit" 1 2 3 15
else
trap "exit" 1 2 3 15
fi #end level 1
if [ "$runoption" != 'Q' ]
then
echo " $i\c" # display repeat number
fi
pwd=`pwd` # remember where we are
cd $testdir # move to the test directory
if [ "$runoption" = "V" ]
then
echo
echo "BENCH COMMAND TO BE EXECUTED:"
echo "$prog $opt"
fi
# execute any prepratory command string
if [ -n "$prep" ]
then
$prep >>$stdout
fi
############ THE BENCH IS TIMED ##############
if test "$stdin" = ""
then # without redirected stdin
time $prog $opt $bgstr 2>>$tmp >>$stdout
else # with redirected stdin
time $prog $opt $bgstr <$stdin 2>>$tmp >>$stdout
fi
time $benchcmd
###############################################
cd $pwd # move back home
status=$? # save the result code
if test $status != 0 # must have been an error
then
if test -f $tmp # is there an error file ?
then
cp $tmp ${TMPDIR}/save.$bench.$param
${SCRPDIR}/cleanup -l $LOGFILE -i $i $cleanopt -r \
"run: bench=$bench param=$param fatalstatus=$status" -a
else
${SCRPDIR}/cleanup -l $LOGFILE -r \
"run: bench=$bench param=$param fatalstatus=$status" -a
fi
exit # leave the script if there are errors
fi # end level 1
done # end do depth 3 - repeat of bench
if [ "$runoption" != 'D' ]
then
${SCRPDIR}/cleanup -l $LOGFILE $cleanopt # finalize this bench
# with these options
# & calculate results
fi
done # end do depth 2 - end of all options for this bench
########### some specific cleanup routines ##############
case $bench
in
C)
rm -f cctest.o a.out
;;
esac
if [ "$runoption" != 'Q' ]
then
echo ""
fi
done # end do level 1 - all benchmarks requested
echo "" >>$LOGFILE
echo " " `who | wc -l` "interactive users." >>$LOGFILE
echo "End Benchmark Run ($date) ...." >>$LOGFILE
if [ "$runoption" != 'Q' ]
then
pg $LOGFILE
fi
exit