sort.src 8.3 KB

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