home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / byteunix.lzh / byte.2 / sort.src < prev   
Text File  |  1990-05-11  |  9KB  |  364 lines

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