home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume11 / musbus / part04 / mkprofile < prev    next >
Encoding:
Text File  |  1987-09-16  |  2.5 KB  |  97 lines

  1. #! /bin/sh
  2. # Incomplete.
  3. # $Header: mkprofile,v 1.2 87/06/23 17:07:28 kjmcdonell Beta $
  4.     profilework)       
  5.             echo ""
  6.             echo "Profile Work Load Test:" >>$LOG
  7.             rate=${rate-2}
  8.             echo "" >>$LOG
  9.             echo "Control parameters: rate=$rate script=script.1" >>$LOG
  10.             echo "" >>$LOG
  11.             if test ! -f makework
  12.             then
  13.                 make makework
  14.             fi
  15.             if test ! -f keyb
  16.             then
  17.                 make keyb
  18.             fi
  19.             tty=${tty-`tty`}
  20.             if test "$tty" = "not a tty"
  21.             then
  22.             tty=/dev/tty
  23.             fi
  24.             chmod +w script.1
  25.             ed - script.1 <<EOF
  26. g/^R=/s/=.*/=$rate/
  27. g/^C=/s,=.*,=$tty,
  28. g/^H=/s,=.*,=.,
  29. g/PATH=/s,=[^:]*:,=`pwd`:,
  30. w
  31. q
  32. EOF
  33.             chmod -w script.1
  34.             log=`pwd`/log.profile
  35.             ( echo "export log;log=$log" ; sed \
  36. -e 's/^export/##&/' \
  37. -e 's/^cd/##&/' \
  38. -e 's,^\([^:][a-zA-Z0-9./]*\)[     ].*,time sh -cx '"'&'"' 2>>$log,' \
  39. -e "s/\('[^$][^$][^']*\)"'\$\$'"/\1'"'$$'"'/g" \
  40. -e "s/\('[^$][^$][^']*\)"'\$\$'"/\1'"'$$'"'/g" \
  41. -e "s/\('[^$][^$][^']*\)"'\$\$'"/\1'"'$$'"'/g" \
  42. -e "s/''//g" \
  43. -e 's/^##//' \
  44. -e 's/^\([a-zA-Z][a-zA-Z0-9]*\)=/export \1;&/' script.1 ) >script.1.time
  45.             s=`cat script.1 | wc -c`
  46.             ts=`cat script.1.time | wc -c`
  47.             rate=`echo "scale=2;$rate*$ts/$s" | bc`
  48.             ed - script.1.time << End-of-File
  49. g/R=/s/=.*/=$rate/
  50. w
  51. q
  52. End-of-File
  53.             echo "Profile run starts ..."
  54.             echo '/bin/sh -ie <script.1.time' >./Workload/workload.time
  55.             trap "./cleanup -w -i $i -t $tmp -a; exit" 1 2 3 4 5 6 7 8 9 10 12 13 14 15
  56.             time ./makework -rc $rate $tty 1 <./Workload/workload.time >$tty 2>>$tmp
  57.             if test $? != 0
  58.             then
  59. #             makework was aborted
  60.             cp $tmp Tmp/save.$n.abort
  61.             ./cleanup -w -i $i -t $tmp -a
  62.             exit
  63.             fi
  64.             ./cleanup -w -t $tmp
  65.             echo "" >>$LOG
  66.             echo "Profile run finished, collect and summarize results ..."
  67.             sed \
  68. -e 's/[     ]*\([0-9][0-9]*\.[0-9]*\)  *real/real   \1\
  69. /' \
  70. -e 's/[     ]*\([0-9][0-9]*\.[0-9]*\)  *user/user   \1\
  71. /' \
  72. -e 's/[     ]*\([0-9][0-9]*\.[0-9]*\)  *sys/sys    \1\
  73. /' \
  74.                 $log \
  75.             | awk '
  76. BEGIN    { printf "\t Real (percent)\t User (percent)\t  Sys (percent)\n" }
  77. /^\+/    { if ($2 != "keyb") {
  78.         c=$2
  79.         cmd[c]=c
  80.       }
  81.       next
  82.     }
  83. /^real/    { r[c]+=$2; totr+=$2; }
  84. /^user/    { u[c]+=$2; totu+=$2; }
  85. /^sys/    { s[c]+=$2; tots+=$2; }
  86. END    { for (c in cmd) {
  87.           printf cmd[c]
  88.           printf "\t%6.1f (%5.2f%%)",r[c],100*r[c]/totr
  89.           printf "\t%6.1f (%5.2f%%)",u[c],100*u[c]/totu
  90.           printf "\t%6.1f (%5.2f%%)\n",s[c],100*s[c]/tots
  91.       }
  92.       printf "-------\n"
  93.       printf "Totals:\t%6.1f\t\t%6.1f\t\t%6.1f\n",totr,totu,tots
  94.     } ' >>$LOG
  95.             ;;
  96.  
  97.