home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / byteunix.lzh / byte.2 / Run < prev    next >
Text File  |  1990-05-11  |  14KB  |  467 lines

  1. #! /bin/sh
  2. #################### set your default list of tests here ##############
  3.  
  4. FULL_SUITE="dhry2 dhry2reg arithoh register short int long float double syscall pipe context1 spawn execl fstime shell dc hanoi"
  5.  
  6. ###############################################################################
  7. #  The BYTE UNIX Benchmarks - Release 2
  8. #          Module: Run   SID: 2.6 4/17/90 16:45:27
  9. #          
  10. ###############################################################################
  11. # Bug reports, patches, comments, suggestions should be sent to:
  12. #
  13. #    Ben Smith,        Rick Grehan, or      Tom Yager at BYTE Magazine
  14. #    ben@bytepb.UUCP   rick_g@bytepb.UUCP   tyager@bytepb.UUCP
  15. # BIX:  bensmith          rick_g               tyager
  16. #
  17. ###############################################################################
  18. #  Modification Log:
  19. # $Header: run,v 5.2 88/01/12 06:23:43 kenj Exp $
  20. #     Ken McDonell, Computer Science, Monash University
  21. #     August 1, 1983
  22. # 3/89 - Ben Smith - BYTE: globalized many variables, modernized syntax
  23. # 5/89 - commented and modernized. Removed workload items till they
  24. #        have been modernized. Added database server test.
  25. # 11/14/89 - Made modifications to reflect new version of fstime
  26. #        and elimination of mem tests.
  27. #
  28. ###############################################################################
  29. ID="@(#)Run:2.6 -- 4/17/90 16:45:27";
  30. version="2.6"
  31. #######################################################################
  32. # General Purpose Benchmark
  33. # based on the work by Ken McDonell, Computer Science, Monash University
  34. #
  35. #  You will need ...
  36. #    awk cat cc chmod comm cp date dc df echo ed expr
  37. #    kill ls make mkdir rm sed test time touch tty umask who
  38. #
  39. #  The following variables may be assigned external values to overide defaults
  40. #
  41. #  Test        Variable    Default        Use
  42. #  all        iterations    6        repeat count for timing
  43. #  dhry        dhryloops    10000        no. of loops to test
  44. #  arithmetic    arithloop    10000        no. of summations
  45. #  hanoi    ndisk        17        list of nos. of disks
  46. #  syscall    ncall        4000        no. iterations, each of
  47. #                          5 system calls
  48. #  context1    switch1        500        no. of switches
  49. #  pipe        io        2048        no. 512 byte blocks to read
  50. #                          and write
  51. #  spawn    children    100        no. of child processes
  52. #  execl    nexecs        100        no. of execs
  53. #  fstime    seconds        1 10 20         seconds
  54. #
  55. umask 022    # at least mortals can read root's files this way
  56. # establish full paths to directories
  57. PWD=`pwd`
  58. HOMEDIR=${HOMEDIR-.}
  59. cd $HOMEDIR
  60. HOMEDIR=`pwd`
  61. cd $PWD
  62.  
  63. BINDIR=${BINDIR-${HOMEDIR}/pgms}
  64. cd $BINDIR
  65. BINDIR=`pwd`
  66. cd $PWD
  67. # let's extend the path to this directory
  68. PATH="${PATH}:${BINDIR}"
  69.  
  70. SCRPDIR=${SCRPDIR-${HOMEDIR}/pgms}
  71. cd $SCRPDIR
  72. SCRPDIR=`pwd`
  73. cd $PWD
  74.  
  75. TMPDIR=${HOMEDIR}/tmp
  76. cd $TMPDIR
  77. TMPDIR=`pwd`
  78. cd $PWD
  79.  
  80. RESULTDIR=${RESULTDIR-${HOMEDIR}/results}
  81. cd $RESULTDIR
  82. RESULTDIR=`pwd`
  83. cd $PWD
  84.  
  85. TIMEACCUM=${TIMEACCUM-${RESULTDIR}/times}
  86.  
  87. TESTDIR=${TESTDIR-${HOMEDIR}/testdir}
  88. cd $TESTDIR
  89. TESTDIR=`pwd`
  90. cd $PWD
  91.  
  92. export BINDIR TMPDIR RESULTDIR PATH TESTDIR TIMEACCUM
  93. #
  94. bell=""
  95. break1="============================================================================="
  96. break2="-----------------------------------------------------------------------------"
  97. #
  98. cat ${BINDIR}/byte.logo # display banner
  99. rm -f ${TIMEACCUM}      # clean out old time accumulation file
  100. echo "kill -9 $$" > ${TMPDIR}/kill_run ; chmod u+x ${TMPDIR}/kill_run
  101. #
  102. arithmetic="arithoh register short int long float double"
  103. system="syscall pipe context1 spawn execl"
  104. misc="C dc hanoi"
  105. dhry="dhry2 dhry2reg" # dhrystone loops
  106. load="shell" # cummulative load tests
  107. db="dbmscli" # add to as new database engines are developed
  108. #
  109. args="" # the accumulator for the bench units to be run
  110. runoption="N"
  111. # generate list of bench programs
  112. for word
  113. do  # do level 1
  114.     case $word
  115.     in
  116.   all)
  117.       ;;
  118.   arithmetic)
  119.       args="$args $arithmetic"
  120.       ;;
  121.   db)
  122.       args="$args $db"
  123.       ;;
  124.   dhry)
  125.       args="$args $dhry"
  126.       ;;
  127.   load)
  128.       args="$args $load"
  129.       ;;
  130.   misc)
  131.       args="$args $misc"
  132.       ;;
  133.   speed)
  134.       args="$args $arithmetic $system"
  135.       ;;
  136.   system)
  137.       args="$args $system"
  138.       ;;
  139.   -q|-Q)
  140.       runoption="Q" #quiet
  141.       ;;
  142.   -v|-V)
  143.       runoption="V" #verbose
  144.       ;;
  145.   -d|-D)
  146.       runoption="D" #debug
  147.       ;;
  148.   *)
  149.       args="$args $word"
  150.       ;;
  151.     esac
  152.  
  153. done # end do level 1
  154. #if no benchmark units have be specified, do them all 
  155. # the - option of set implies no options; any list following
  156. # becomes the line arguments (replacing any that may exist)
  157. set - $args
  158. if test $# -eq 0  #no arguments specified
  159.    then
  160.    set - $FULL_SUITE
  161. fi
  162.  
  163. if test "$runoption" = 'D'
  164. then
  165.   set -x
  166.   set -v
  167. fi
  168.  
  169. date=`date`
  170. tmp=${TMPDIR}/$$.tmp
  171. timeaccum=${TMPDIR}/time.accum
  172. LOGFILE=${RESULTDIR}/log
  173. #add old log to accumulated log or move it
  174. if test -w ${RESULTDIR}/log
  175. then
  176.    if test -w ${RESULTDIR}/log.accum
  177.    then
  178.       cat ${RESULTDIR}/log >> ${RESULTDIR}/log.accum
  179.       rm ${RESULTDIR}/log
  180.    else
  181.       mv ${RESULTDIR}/log ${RESULTDIR}/log.accum
  182.    fi
  183. fi
  184. echo "Start Benchmark Run (BYTE Version $version)" >>$LOGFILE
  185. echo "  $date " >>$LOGFILE
  186. echo " " `who | wc -l` "interactive users." >>$LOGFILE
  187. #if SysV use 'uname -a' -- if BSD use 'hostname'
  188. uname -a >>$LOGFILE
  189. # hostname >>$LOGFILE
  190. #
  191. #if not specified, do each bench 6 iterations
  192. iter=${iterations-6}
  193. if test $iter -eq 6
  194. then
  195.   longloop="1 2 3 4 5 6"
  196.   shortloop="1 2 3"
  197. else  # generate list of loop numbers
  198.   short=`expr \( $iter + 1 \) / 2`
  199.   longloop=""
  200.   shortloop=""
  201.   while test $iter -gt 0
  202.   do # do level 1
  203.        longloop="$iter $longloop"
  204.        if test $iter -le $short
  205.        then
  206.          shortloop="$iter $shortloop"
  207.        fi
  208.        iter=`expr $iter - 1`
  209.   done # end do level 1
  210. fi #loop list genration
  211. ####################################################################
  212. ############## the major control loop ##############################
  213. ####################################################################
  214. for bench # line argument processing
  215. do # do level 1
  216.     # set some default values
  217.     prog=${BINDIR}/$bench  # the bench name is default program
  218.     need=$prog             # we need the at least the program
  219.     paramlist="#"          # a dummy parameter to make anything run
  220.     testdir="${TESTDIR}"   # the directory in which to run the test
  221.     prepcmd=""             # preparation command or script
  222.     parammsg=""
  223.     repeat="$longloop"
  224.     stdout="$LOGFILE"
  225.     stdin=""
  226.     cleanopt="-t $tmp"
  227.     bgnumber=""
  228.     trap "${SCRPDIR}/cleanup -l $LOGFILE -a; exit" 1 2 3 15
  229.     if [ $runoption != 'Q' ]
  230.     then
  231.        echo "$bench: \c"
  232.     fi
  233.     echo "" >>$LOGFILE
  234.     ###################### select the bench specific values ##########
  235.     case $bench
  236.     in
  237.   dhry2)
  238.     options=${dhryloops-10000}
  239.     logmsg="Dhrystone 2 without register variables"
  240.     cleanopt="-d $tmp"
  241.     ;;
  242.  
  243.   dhry2reg)
  244.     options=${dhryloops-10000}
  245.     logmsg="Dhrystone 2 using register variables"
  246.     cleanopt="-d $tmp"
  247.     ;;
  248.  
  249.   arithoh|register|short|int|long)
  250.     options=${arithloop-10000}
  251.     logmsg="Arithmetic Test (type = $bench): $options Iterations"
  252.     ;;
  253.  
  254.   float|double)
  255.     options=${arithloop-10000}
  256.     logmsg="Arithmetic Test (type = $bench): $options Iterations"
  257.     ;;
  258.  
  259.   dc)  need=dc.dat
  260.     prog=dc
  261.     options=""
  262.     stdin=dc.dat
  263.     stdout=/dev/null
  264.     logmsg="Arithmetic Test (sqrt(2) with dc to 99 decimal places)"
  265.     ;;
  266.  
  267.   hanoi)  options='$param'
  268.     stdout=/dev/null
  269.     logmsg="Recursion Test: Tower of Hanoi Problem"
  270.     paramlist="${ndisk-17}"
  271.     parammsg='$param Disk Problem:'
  272.     ;;
  273.  
  274.   syscall)
  275.     options=${ncall-4000}
  276.     logmsg="System Call Overhead Test: 5 x $options Calls"
  277.     ;;
  278.  
  279.   context1)
  280.     options=${switch1-500}
  281.     logmsg="Pipe-based Context Switching Test: 2 x $options Switches"
  282.     ;;
  283.  
  284.   pipe)   options=${io-2048}
  285.     logmsg="Pipe Throughput Test: read & write $options x 512 byte blocks"
  286.     ;;
  287.  
  288.   spawn)  options=${children-100}
  289.     logmsg="Process Creation Test: $options forks"
  290.     ;;
  291.  
  292.   execl)  options=${nexecs-100}
  293.     logmsg="Execl Throughput Test: $options execs"
  294.     ;;
  295.  
  296.   fstime) 
  297.     where=${where-${TMPDIR}}
  298.     options='$param '"$where"
  299.     logmsg="Filesystem Throughput Test:"
  300.     paramlist=${seconds-"1 10 20"}
  301.     parammsg='Test Time: $param secs'
  302.     cleanopt="-f $tmp"
  303.     ;;
  304.  
  305.   C)   need=cctest.c
  306.     prog=cc
  307.     options='$param'
  308.     stdout=/dev/null
  309.     repeat="$shortloop"
  310.     logmsg="C Compiler Test:"
  311.     paramlist="cctest.c"
  312.     parammsg='cc $param'
  313.     rm -f a.out
  314.     ;;
  315. dbmscli)
  316.     repeat="$shortloop"
  317.     need="db.dat"
  318.                           #                   records queuespace
  319.     prepcmd='${BINDIR}/dbprep ${testdir}/db.dat 1000    1024'
  320.     paramlist=${clients-"1 2 4 8"}
  321.     parammsg='$param client processes.'
  322.     logmsg="Client/Server Database Engine:"
  323.     options='${testdir}/db.dat $param 0 1000'  # $param clients;
  324.                            # 0 sleep; 1000 iterations
  325.     ;;
  326. shell)
  327.     prog="multi.sh"
  328.     repeat="$shortloop"
  329.     logmsg="Bourne shell script and Unix utilities"
  330.     paramlist=${background-"1 2 4 8 "}
  331.     parammsg='$param concurrent background processes'
  332.     bgnumber='$param'
  333.     ;;
  334.   *)   ${BINDIR}/cleanup -l $LOGFILE -r "run: unknown benchmark \"$bench\"" -a
  335.     exit 1
  336.     ;;
  337. esac
  338. ################################################################
  339. ###################### the main task ###########################
  340. ###################### run the bench ###########################
  341. ################################################################
  342. # each of those variables are now used in a general way
  343. #
  344. echo "$break1" >>$LOGFILE                 # break between bench pgms
  345. echo "$logmsg" >>$LOGFILE                 # benchmark name
  346.     for param in $paramlist
  347.     do   # level 2
  348.       param=`echo $param | sed 's/_/ /g'` # be sure that spaces are used
  349.                       # underscore can couple params
  350.       if [ "$runoption" != "Q" ]
  351.       then
  352.          echo "\n   [$param] -\c"           # generate message to user
  353.       fi
  354.       eval msg='"'$parammsg'"'            # the eval is used to
  355.       echo "$break2" >>$LOGFILE           # break between bench pgms
  356.       if test "$msg"                      # evaluate any embedded
  357.       then                                # variables in the parammsg
  358.           echo "$msg" >>$LOGFILE
  359.       fi
  360.  
  361.       eval opt='"'$options'"'         # evaluate any vars in options
  362.       eval prep='"'$prepcmd'"'         # evaluate any prep command
  363.       eval bg='"'$bgnumber'"'         # evaluate bgnumber string
  364.       rm -f $tmp             # remove any tmp files
  365.  
  366.       # if the test requires mulitple concurrent processes,
  367.       # prepare the background process string (bgstr)
  368.       # this is just a string of "+"s that will provides a
  369.       # parameter count for a "for" loop
  370.       bgstr=""
  371.       if test "$bg" != ""
  372.       then
  373.       count=`expr "$bg"`
  374.           while test $count -gt 0
  375.           do
  376.           bgstr="+ $bgstr"
  377.           count=`expr $count - 1`
  378.       done
  379.       fi
  380.       #
  381.       for i in $repeat             # loop for the specified number
  382.       do  # do depth 3
  383.           if [ "$runoption" != 'D' ]  # level 1
  384.       then
  385.         # regular Run - set logfile to go on signal
  386.             trap "${BINDIR}/cleanup -l $LOGFILE -i $i $cleanopt -a; exit" 1 2 3 15
  387.       else
  388.             trap "exit" 1 2 3 15
  389.       fi #end level 1
  390.           if [ "$runoption" != 'Q' ]
  391.       then
  392.           echo " $i\c"                  # display repeat number
  393.       fi
  394.       pwd=`pwd`                     # remember where we are
  395.       cd $testdir                   # move to the test directory
  396.       if [ "$runoption" = "V" ]
  397.       then
  398.         echo
  399.         echo "BENCH COMMAND TO BE EXECUTED:"
  400.         echo "$prog $opt"
  401.       fi
  402.  
  403.       # execute any prepratory command string
  404.       if [ -n "$prep" ]
  405.       then
  406.         $prep 2>&1 >>$stdout 
  407.       fi
  408.       ############ THE BENCH IS TIMED ##############
  409.           if test "$stdin" = ""  
  410.           then # without redirected stdin
  411.              time $prog $opt $bgstr 2>>$tmp >>$stdout
  412.           else # with redirected stdin
  413.              time $prog $opt $bgstr <$stdin 2>>$tmp >>$stdout
  414.           fi 
  415.       time $benchcmd
  416.       ###############################################
  417.       cd $pwd                    # move back home
  418.           status=$?                  # save the result code
  419.           if test $status != 0 # must have been an error
  420.           then
  421.            if test -f $tmp # is there an error file ?
  422.            then
  423.                 cp $tmp ${TMPDIR}/save.$bench.$param
  424.             ${SCRPDIR}/cleanup -l $LOGFILE -i $i $cleanopt -r \
  425.            "run: bench=$bench param=$param fatalstatus=$status" -a
  426.            else
  427.             ${SCRPDIR}/cleanup -l $LOGFILE -r \
  428.            "run: bench=$bench param=$param fatalstatus=$status" -a
  429.            fi 
  430.            exit # leave the script if there are errors
  431.           fi # end  level 1
  432.       done # end do depth 3 - repeat of bench
  433.       if [ "$runoption" != 'D' ]
  434.       then
  435.         ${SCRPDIR}/cleanup -l $LOGFILE $cleanopt # finalize this bench
  436.                          # with these options
  437.                          # & calculate results
  438.       fi
  439.     done # end do depth 2 - end of all options for this bench
  440.  
  441.     ########### some specific cleanup routines ##############
  442.     case $bench
  443.     in
  444.       C)
  445.       rm -f cctest.o a.out
  446.       ;;
  447.  
  448.       fstime)
  449.       sync; sleep 20
  450.       ;;
  451.     esac
  452.     if [ "$runoption" != 'Q' ]
  453.     then
  454.        echo ""
  455.     fi
  456. done # end do level 1  - all benchmarks requested
  457. ########## a few last items for the end ##############
  458. echo "" >>$LOGFILE
  459. echo " " `who | wc -l` "interactive users." >>$LOGFILE
  460. echo "End Benchmark Run ($date) ...." >>$LOGFILE
  461. if [ "$runoption" != 'Q' ]
  462. then
  463.   pg $LOGFILE
  464. fi
  465. exit
  466. ########################### Amen ######################
  467.