Doxygen changes
[ACE_TAO.git] / ACE / bin / generate_compile_stats.sh
blob921119ca8695cce065fe446258b3e0187fccbb3a
1 #! /bin/sh
3 # This script generate metrics html pages for either compile times or
4 # footprint.
6 # Compile times:
7 # Parse the build.txt file from an autobuild that was generated with the
8 # g++_metric.sh script, e.g., with CXX=g++_metric.sh which outputs
9 # compile times on a per object basis, and use the data to generate time
10 # series graphs with gnuplot.
12 # Footprint:
13 # Parse the build.txt file and and the *.map files, generated with LDFLAGS
14 # set to =-Xlinker -M -Xlinker -Map -Xlinker \$@.map and static_libs_only=1.
16 # For use with an autobuild, place a line something like this in the xml file,
17 # after the log file is closed, but before it's moved.
19 # <command name="shell" options="$ACE_ROOT/bin/generate_compile_stats.sh <path>/build.txt <destination> Footprint" />
22 ###############################################################################
24 # usage
26 ###############################################################################
27 usage ()
29 echo "Usage: `basename $0` [--base=<dir>] [--name=<name>] [--compiler=compiler]"
30 echo " <input_file> <destination_directory> [target_file]"
31 echo " [Footprint|Compilation] [<date>] [<fudge_factor>]"
32 echo ""
33 echo "--base This option can be used to set the base root directory to"
34 echo " something other than the default \$ACE_ROOT."
35 echo "--name This option can be used to set the software title to something"
36 echo " other than the default ACE+TAO+CIAO+DAnCE."
37 echo "--compiler This option can be used to set the compiler to something"
38 echo " other than the default gcc."
39 echo "input_file This is the compilation log file."
40 echo "destination_directory This designates the location of the generated html."
41 echo "target_file This is similar to input_file, but should contain no errors."
42 echo "date Set the date used in all generated html pages."
43 echo "fudge_factor Add the specified number of seconds to the compilation time"
44 echo " for each target."
45 echo ""
46 echo "Options must be specified in the order shown above."
47 exit
50 ###############################################################################
52 # parse_time
54 # this only works for english
55 # assumes the date is formatted like this: Sat Apr 12 18:19:31 UTC 2003
56 # and outputs this: 2003/04/12-18:19
58 ###############################################################################
59 parse_time ()
61 # todo: add a format parameter
62 local INDEX=0
63 local PT_MONTH=""
64 local PT_DAY=""
65 local PT_YEAR=""
66 local PT_HOUR=""
67 local PT_MINUTE=""
68 local PT_SECOND=""
69 local PT_TIMEZONE=""
71 read -a line
72 for token in "${line[@]}"; do
73 #echo "$INDEX = $token"
74 case $INDEX in
75 1 ) case $token in
76 Jan ) PT_MONTH="01" ;;
77 Feb ) PT_MONTH="02" ;;
78 Mar ) PT_MONTH="03" ;;
79 Apr ) PT_MONTH="04" ;;
80 May ) PT_MONTH="05" ;;
81 Jun ) PT_MONTH="06" ;;
82 Jul ) PT_MONTH="07" ;;
83 Aug ) PT_MONTH="08" ;;
84 Sep ) PT_MONTH="09" ;;
85 Oct ) PT_MONTH="10" ;;
86 Nov ) PT_MONTH="11" ;;
87 Dec ) PT_MONTH="12" ;;
88 esac ;;
89 2 ) PT_DAY="$token" ;;
90 3 ) PT_HOUR="${token%%:*}"
91 PT_MINUTE="${token%:*}"
92 PT_MINUTE="${PT_MINUTE#*:}"
93 PT_SECOND="${token##*:}" ;;
94 4 ) PT_TIMEZONE="$token" ;;
95 5 ) PT_YEAR="$token" ;;
96 esac
97 let INDEX=$INDEX+1
98 done
99 if [ "$1" = "debug" ]; then
100 echo "month = $PT_MONTH"
101 echo "day = $PT_DAY"
102 echo "year = $PT_YEAR"
103 echo "hour = $PT_HOUR"
104 echo "min = $PT_MINUTE"
105 echo "sec = $PT_SECOND"
106 echo "tz = $PT_TIMEZONE"
108 echo "$PT_YEAR/$PT_MONTH/$PT_DAY-$PT_HOUR:$PT_MINUTE"
111 ###############################################################################
113 # strip_date
115 # grab date from line with following format:
116 # ################### End [Fri Apr 11 00:18:31 2003 UTC]
117 # and return it in this format: Fri Apr 11 00:18:31 UTC 2003 which is
118 # what parse_time() expects
120 ###############################################################################
121 strip_date ()
123 local INDEX=0
124 local TEMP_DATE=""
125 local DATE=""
126 read -a line
127 for token in "${line[@]}"; do
128 #echo "$INDEX = $token"
129 case $INDEX in
130 2 ) DATE=${token#[} ;;
131 7 ) DATE="$DATE ${token%]} $TEMP_DATE" ;;
132 # this is a hack since the autobuild scripts don't format the date
133 # correctly... :-(
134 6 ) TEMP_DATE=$token ;;
135 * ) DATE="$DATE $token" ;;
136 esac
137 let INDEX=$INDEX+1
138 done
139 echo $DATE
142 ###############################################################################
144 # parse
146 # Parse the commandline and validate the inputs
148 ###############################################################################
149 parse ()
151 echo "parse()"
152 while [ $# -gt 1 ]; do
153 if [ -n "`echo $1 | grep '^--base=.*'`" ]; then
154 BASE_ROOT=`echo $1 | sed 's/^--base=//'`
155 shift
156 elif [ -n "`echo $1 | grep '^--name=.*'`" ]; then
157 BASE_TITLE=`echo $1 | sed 's/^--name=//'`
158 shift
159 elif [ -n "`echo $1 | grep '^--compiler.*'`" ]; then
160 COMPILER=`echo $1 | sed 's/^--compiler=//'`
161 shift
162 else
163 break
165 done
167 # set input file and destination (required)
168 if [ $# -gt 1 ]; then
169 INFILE=$1
170 DEST=$2
172 if ! [ -e "$INFILE" ]; then
173 echo "input_file $INFILE does not exist."
174 usage
176 else
177 usage
180 # set the target file from command line
181 if [ $# -gt 2 ]; then
182 TARGETS=$3
183 else
184 TARGETS=$INFILE
187 # set type of metric from command line
188 if [ $# -gt 3 ]; then
189 METRIC=$4
190 else
191 METRIC="Compilation"
193 echo "metric = ($METRIC)"
195 # set the date from command line
196 if [ $# -gt 4 ]; then
197 DATE=$5
198 else
199 DATE=`tail -n 1 $INFILE | strip_date | parse_time`
201 echo "date = ($DATE)"
203 # set fudge factor from commandline (for testing)
204 if [ $# -gt 5 ]; then
205 FUDGE_FACTOR=$6
206 else
207 FUDGE_FACTOR=0
211 ###############################################################################
213 # gen_chart
215 # Generate the actual charts and move them to ${DEST}
217 ###############################################################################
218 gen_chart ()
220 local object=$1
221 local DEST=$2
222 local TYPE=$3
223 local EXT="txt"
224 local YLABEL="Compile Time (Seconds)"
225 local FACTOR=1
226 local low=$4
227 local high=$5
229 if [ "$TYPE" = "Footprint" ]; then
230 EXT="size"
231 if [ ${high} -gt 1024 ]; then
232 YLABEL="Footprint (KBytes)"
233 FACTOR=1024
234 else
235 YLABEL="Footprint (Bytes)"
236 FACTOR=1
240 let low="${low}/${FACTOR}"
241 let high="${high}/${FACTOR}"
243 sort -t'/' -k1n -k2n -k3n ${DEST}/data/${object}.${EXT} | grep -E ^2 > tmp.txt
245 gnuplot <<EOF
246 set data style lp l
247 set time "$DATE"
248 set xdata time
249 set timefmt "%Y/%m/%d-%H:%M"
250 set format x "%Y/%m/%d"
251 set xtics rotate
252 set xlabel 'Date (YYYY/MM/DD)' 0,-3
253 set ylabel "${YLABEL}"
254 set terminal png small size 1024,768 color
255 set yrange [0:]
256 set output "${DEST}/images/${object}_${TYPE}.png"
257 set title "${object//___//}"
258 plot 'tmp.txt' using 1:(\$2/$FACTOR) notitle w points, 'tmp.txt' using 1:(\$2/$FACTOR) notitle w l lt 3 lw 4
259 exit
262 # here's how to reduce the scale
263 # plot '$1' using 1:(\$2/1024.0) title '$3' w l
266 ###############################################################################
268 # create_dirs
270 # Make sure hidden directory tree exists, and create it if it doesn't
272 ###############################################################################
273 create_dirs ()
275 echo "create_dirs() '$1'"
276 if ! [ -d "${1}" ]; then
277 mkdir -p ${1}
279 if ! [ -d "${1}data" ]; then
280 mkdir -p ${1}data
282 if ! [ -d "${1}images" ]; then
283 mkdir -p ${1}images
287 ###############################################################################
289 # process_file
291 # Process the the $INPUT file
293 ###############################################################################
294 process_file ()
296 echo "process_file()"
298 local CURRENT_TIME=0
299 local CURRENT_OBJECT=""
300 local CURRENT_PATH=""
301 local seconds=0
302 local hundreths=0
304 while read target usertime systemtime; do
306 # get path
307 CURRENT_PATH=${target%/*}
309 # strip off the hidden directory if needbe
310 CURRENT_PATH=${CURRENT_PATH%/.*}
312 # replace all "/" with "___"
313 # (so we can keep them all in the same directory)
314 CURRENT_PATH=${CURRENT_PATH//\//___}
316 # strip path off of target
317 CURRENT_OBJECT=${CURRENT_PATH}___${target##*/}
318 #echo "target = $target, object = $CURRENT_OBJECT, path = $CURRENT_PATH"
319 #echo "usertime = $usertime, systemtime = $systemtime"
321 let seconds="${usertime%.*}+${systemtime%.*}"
323 # it's just easier to grab the values first, since .0n causes problems...
324 userdec="${usertime#*.}"
325 userdec=${userdec#0}
326 systemdec="${systemtime#*.}"
327 systemdec=${systemdec#0}
328 let hundreths="${userdec}+${systemdec}"
330 let CURRENT_TIME="(${seconds}*100 + ${hundreths})+$FUDGE_FACTOR"
331 echo $DATE $CURRENT_TIME >> ${DEST}/data/${CURRENT_OBJECT}.txt
333 done # while
336 ###############################################################################
338 # composite_list
340 ###############################################################################
341 composite_list ()
343 local FOUND_OBJ=0
344 local BASE_OBJ_FLAG=0
345 local BASE_OBJ=""
346 local OBJ_LIST=""
347 local DIR_LINE=0
348 local DIR=""
349 local INDEX=0
351 while read -a line; do
352 DIR_LINE=0
353 INDEX=0
355 for i in "${line[@]}"; do
356 if [ $DIR_LINE -eq 1 ]; then
358 # only process when entering a directory
359 if [ $INDEX -eq 1 ] && [ "$i" = "Leaving" ]; then
360 DIR=""
361 break
364 if [ $INDEX -eq 3 ]; then
365 DIR="${i%?}" # strip off last "'"
366 DIR="${DIR#*$BASE_ROOT/}" # strip off $BASE_ROOT
367 DIR="${DIR//\//___}___" # replace "/" with "___"
368 break
369 else
370 let INDEX="$INDEX+1"
371 continue
375 # if it was a "make" line then continue to the next token which will
376 # continue to process above
377 if [ "${i%[*}" = "make" ] || [ "${i%:*}" = "make" ]; then
378 DIR=""
379 let DIR_LINE=1
380 let INDEX="$INDEX+1"
381 continue
384 # not an "make" line, so process it here.
385 if [ $BASE_OBJ_FLAG -eq 1 ]; then
386 BASE_OBJ="${DIR}${i##.*/}"
387 # strip off lib numbers
388 if [ "$BASE_OBJ" != "${BASE_OBJ%.so.*}" ]; then
389 BASE_OBJ=${BASE_OBJ%.so.*}.so
391 BASE_OBJ_FLAG=0
392 elif [ "$i" = "-o" ]; then
393 # found our base object, set flag so we can grab the next one
394 BASE_OBJ_FLAG=1
395 elif [ "$i" = "${i#-}" -a "$i" = "${i#/}" -a "$i" != "${i%.o}" ]; then
396 OBJ_LIST="$OBJ_LIST ${DIR}${i##*/}"
397 FOUND_OBJ=1
399 done # for
400 if [ $FOUND_OBJ -eq 1 ]; then
401 echo "$BASE_OBJ : $OBJ_LIST"
402 FOUND_OBJ=0
403 OBJ_LIST=""
404 BASE_OBJ=""
406 done # while
409 ###############################################################################
411 # create_composite_list
413 ###############################################################################
414 create_composite_list ()
416 echo "create_composite_list()"
417 local INFILE=$1
419 # create a pattern file
420 echo "\-L" > ${DEST}/comp_match.txt
421 echo "Entering directory" >> ${DEST}/comp_match.txt
423 # grep out the entering directory line and all the link lines,
424 # but only keep entering directory lines preceeding link lines.
425 cat $INFILE | grep -f ${DEST}/comp_match.txt | grep -B1 "\-L" \
426 | grep -ve "--" | composite_list > ${DEST}/composites.txt
429 ###############################################################################
431 # library_list
433 ###############################################################################
434 library_list ()
436 local FOUND_OBJ=0
437 local BASE_OBJ_FLAG=0
438 local BASE_OBJ=""
439 local OBJ_LIST=""
440 local DIR_LINE=0
441 local DIR=""
442 local INDEX=0
444 while read -a line; do
445 DIR_LINE=0
446 INDEX=0
447 for i in "${line[@]}"; do
448 if [ $DIR_LINE -eq 1 ]; then
449 if [ $INDEX -eq 3 ]; then
450 DIR="${i%?}" # strip off last "'"
451 DIR="${DIR#*$BASE_ROOT/}" # strip off $BASE_ROOT
452 DIR="${DIR//\//___}___" # replace "/" with "___"
453 break
454 else
455 let INDEX="$INDEX+1"
456 continue
460 # if it was a "make" line then continue to the next token which will
461 # continue to process above
462 if [ "${i%[*}" = "make" ]; then
463 let DIR_LINE=1
464 let INDEX="$INDEX+1"
465 continue
468 # not a "make" line, so process it here. We are interested in the
469 # 3rd, and last, token, i.e., lib*.a
470 let INDEX="$INDEX+1"
471 if [ $INDEX -eq 3 ]; then
472 echo "$DIR$i"
474 done # for
475 done # while
478 ###############################################################################
480 # create_library_list
482 ###############################################################################
483 create_library_list ()
485 echo "create_library_list()"
486 local INFILE=$1
488 # create a pattern file
489 echo "chmod" > ${DEST}/lib_match.txt
490 echo "Entering directory" >> ${DEST}/lib_match.txt
492 # grep out the entering directory line and all the link lines,
493 # but only keep entering directory lines preceeding link lines.
494 cat $INFILE | grep -f ${DEST}/lib_match.txt | grep -B1 "chmod" \
495 | grep -ve "--" | library_list > ${DEST}/libraries.txt
498 ###############################################################################
500 # rollup_compile_times
502 ###############################################################################
503 rollup_compile_times ()
505 echo "process_composite_objects()"
506 local TOTAL_TIME=0
507 local temp
508 local tdate=""
509 local ttime=0
510 local lpath="${DEST}/data/"
512 # rollup compile times
513 while read outfile colon infiles; do
514 #echo "$outfile ----- $infiles"
515 for i in $infiles; do
516 temp=`head -n 1 ${lpath}${i}.txt`
517 tdate=${temp%% *}
518 let ttime="${temp##* }"
520 if [ "$tdate" = "$DATE" ]; then
521 let TOTAL_TIME="$TOTAL_TIME + ${ttime}"
523 done # for
524 echo "$DATE $TOTAL_TIME" >> ${lpath}${outfile}.txt
525 let TOTAL_TIME=0
526 done # while
529 ###############################################################################
531 # footprint
533 ###############################################################################
534 footprint ()
536 echo "footprint()"
537 local TYPE="$1"
538 local fpath=""
539 local lpath="${DEST}/data/"
540 local FILE=""
541 local SIZE=""
543 # Remove the old size_composites.txt and create a new one since
544 # we have all the info we need from the size command on a library.
545 if [ "$TYPE" = "LIB" ] && [ -e ${DEST}/size_composites.txt ]; then
546 rm ${DEST}/size_composites.txt
549 # go through all the targets and get the sizes of the target and
550 # each dependent object and write it to a *.size file.
551 while read outfile colon infiles; do
552 # reconstitue file name
553 FILE="$BASE_ROOT/${outfile//___//}"
555 if [ -e $FILE ]; then
556 #echo "inside if"
557 SIZE=`size $FILE | grep -v text | awk '{s += \$4} END {print s}'`
558 echo "$DATE $SIZE" >> $lpath/${outfile}.size
560 # only process the included objects if it's a library
561 if [ "$TYPE" = "LIB" ]; then
562 fpath=${FILE%/*}
563 # now, do the same for all the objects in the file (if any)
564 size $FILE |
565 grep -v text |
566 awk '{print $4 " : " $6}' | process_included $fpath $lpath $FILE
570 done # while
573 ###############################################################################
575 # process_included
577 ###############################################################################
578 process_included ()
580 echo "process_included()"
581 local fpath=$1
582 local lpath=$2
583 local LIBRARY=$3
584 local FILE=""
585 local OUTFILE=""
587 # while we are here, and have the info, go ahead and write out
588 # size dependencies for each library.
589 LIBRARY="${LIBRARY#*$BASE_ROOT/}" # strip off $BASE_ROOT
590 LIBRARY="${LIBRARY//\//___}" # replace "/" with "___"
591 echo -n "$LIBRARY : " >> ${DEST}/size_composites.txt
593 while read size colon file; do
594 FILE=$fpath/$file
595 OUTFILE="${FILE#*$BASE_ROOT/}" # strip off $BASE_ROOT
596 OUTFILE="${OUTFILE//\//___}" # replace "/" with "___"
597 #echo "size = ($size)"
598 echo "$DATE $size" >> $lpath/${OUTFILE}.size
600 # add the object
601 echo -n "$OUTFILE " >> ${DEST}/size_composites.txt
603 done
604 # add newline
605 echo "" >> ${DEST}/size_composites.txt
609 ###############################################################################
611 # process_map_file
613 ###############################################################################
614 process_map_file ()
616 # this is way too noisy...
617 #echo "process_map_file()"
618 local index=0
619 local INFILE=$1
620 local FILE=""
622 # Read in the map file. The first section is all we are interested
623 # in right now. As soon as we see "Memory Configuration" we are done.
624 while read line; do
625 let index=$index+1
626 # Skip the first 2 lines, then read in all the odd lines, they are the
627 # objects that must be loaded. The following line, even lines, is the
628 # object that caused it to be loaded.
629 if [ $index -lt 3 ] || [ "$line" = "" ]; then
630 continue
633 # The line looks like this:
634 #/ace_root_path/ace/libACE.a(Malloc.o)
635 # need to find the real library path, since these libs will
636 # always be in ace/, but the objects will be in the original
637 # location.
638 lib="${line##/*/}" # strip off path, but only if it starts a line
639 lib="${lib%%.a*}" # strip off rest of line
640 lib="$lib.a" # put back the .a to make it unambiguous
641 libpath=`grep $lib ${DEST}/libraries.txt`
642 path="${libpath%___lib*}" # strip off libname
643 FILE="${line#*(}" # strip off everything up to object name
644 FILE="${FILE%%)*}" # strip off rest of line
645 FILE="${path}___${FILE}"
646 echo -n "$FILE " >> ${DEST}/size_composites.txt
647 done
649 echo "" >> ${DEST}/size_composites.txt
653 ###############################################################################
655 # create_size_composites
657 ###############################################################################
658 create_size_composites ()
660 echo "create_size_composites()"
661 local FILE=""
663 while read outfile colon infiles; do
664 # reconstitue file name
665 FILE="$BASE_ROOT/${outfile//___//}.map"
666 if [ -e $FILE ]; then
667 echo -n "$outfile : " >> ${DEST}/size_composites.txt
668 # only process lines that don't begin with a space
669 cat $FILE | sed -e '/Memory Configuration/,$d' \
670 | sed -e '/Allocating common symbols/,$d' \
671 | grep -v "^ " | process_map_file $FILE
673 #break
674 done
678 ###############################################################################
680 # create_images
682 ###############################################################################
683 create_images ()
685 echo "create_images()"
687 local DEST=$1
688 local TYPE=$2
689 local LOW=0
690 local HIGH=5000
691 local STEP=0
692 local TMP=0
694 while read object; do
695 if [ -e $object ] && [ `sort -t'/' -k1n -k2n -k3n $object | grep -E ^2 | tail -n 1 | cut -d' ' -f2` ]; then
696 let TMP=`sort -t'/' -k1n -k2n -k3n $object | grep -E ^2 | tail -n 1 | cut -d' ' -f2`
697 let TMP=$TMP*16/10
698 STEP=100
699 HIGH=0
700 while [ $HIGH -eq 0 ]; do
701 if [ $TMP -lt $STEP ]; then
702 HIGH=$STEP
704 let STEP=$STEP*15/10
705 done
707 if [ "$TYPE" = "Footprint" ]; then
708 object="${object%.size}"
709 else
710 object="${object%.txt}"
713 gen_chart "${object##*/}" ${DEST} ${TYPE} ${LOW} ${HIGH} >/dev/null 2>&1
715 done
719 ###############################################################################
721 # create_index_page
723 ###############################################################################
724 create_index_page ()
726 local TYPE="$1"
727 local TITLE="$TYPE metrics for $BASE_TITLE"
729 echo "<html>"
730 echo "<head><title>$TITLE</title></head>"
731 echo '<style><!--'
732 echo 'body,td,a,p,.h{font-family:arial,sans-serif;}'
733 echo '.h{font-size: 20px;}'
734 echo '.q{text-decoration:none; color:#0000cc;}'
735 echo '//-->'
736 echo '</style>'
737 echo '<body text = "#000000" link="#000fff" vlink="#ff0f0f" bgcolor="#ffffff">'
738 echo "<br><center><h1>$TITLE</h1></center><br><hr>"
739 if [ $BASE_TITLE = $DEFAULT_TITLE ]; then
740 echo '<p>We are measuring ACE+TAO+CIAO+DAnCE metrics daily.'
741 else
742 echo '<p>'
744 echo ' Metrics are gathered nightly on all
745 objects in the '$BASE_TITLE' distribution and displayed here.'
746 echo '<ul>'
747 if [ $BASE_TITLE = $DEFAULT_TITLE ]; then
748 echo "<li><a href=\"ace_${TYPE}.html\">ACE</a>"
749 echo "<li><a href=\"tao_${TYPE}.html\">TAO</a>"
750 echo "<li><a href=\"ciao_${TYPE}.html\">CIAO</a>"
751 echo "<li><a href=\"dance_${TYPE}.html\">DAnCE</a>"
752 else
753 echo "<li><a href=\"all_${TYPE}.html\">ALL</a>"
755 echo '</ul>'
756 echo '<hr>'
758 echo '<P>All the experiments run on the system described below. '
759 echo 'The machine is running Linux ('
761 if [ -e "/etc/SuSE-release" ]; then
762 cat /etc/SuSE-release
765 if [ -e "/etc/redhat-release" ]; then
766 cat /etc/redhat-release
769 echo "), and we use " $COMPILER " version "
771 $COMPILER -dumpversion > ${DEST}/compilerversion.txt 2>&1
772 cat ${DEST}/compilerversion.txt
774 echo ' to compile '$BASE_TITLE'. </P>'
776 if [ -z "$MPC_ROOT" ]; then
777 MPC_ROOT=$ACE_ROOT/MPC
780 CFG_FILES=$ACE_ROOT/ace/config.h
781 if [ -r $ACE_ROOT/bin/MakeProjectCreator/config/default.features ]; then
782 CFG_FILES="$CFG_FILES $ACE_ROOT/bin/MakeProjectCreator/config/default.features"
783 elif [ -r $MPC_ROOT/config/default.features ]; then
784 CFG_FILES="$CFG_FILES $MPC_ROOT/config/default.features"
786 CFG_FILES="$CFG_FILES $ACE_ROOT/include/makeinclude/platform_macros.GNU"
788 echo '<TABLE border="2"><TBODY>'
789 for cfg_file in $CFG_FILES; do
790 if [ -r $cfg_file ]; then
791 echo "<TR><TD>ACE+TAO+CIAO+DAnCE Configuration</TD><TD>`basename $cfg_file`</TD></TR>"
792 echo '<TR><TD colspan="2"><PRE>'
793 cat $cfg_file
794 echo '</PRE></TD></TR>'
796 done
798 echo '<TR><TD>CPU Information</TD><TD>/proc/cpuinfo</TD></TR>'
799 echo '<TR><TD colspan="2"><PRE>'
801 cat /proc/cpuinfo
803 echo '</PRE></TD></TR><TR><TD>Available Memory</TD><TD>/proc/meminfo</TD></TR>'
804 echo '<TR><TD colspan="2"><PRE>'
806 cat /proc/meminfo
808 echo '</PRE></TD></TR><TR><TD>OS Version</TD><TD>uname -a</TD></TR>'
809 echo '<TR><TD colspan="2"><PRE>'
811 /bin/uname -a
813 echo '</PRE></TD></TR><TR><TD>Compiler Version</TD><TD>'$COMPILER' -v</TD></TR>'
814 echo '<TR><TD colspan="2">'
816 $COMPILER -v > ${DEST}/compiler.txt 2>&1
817 cat ${DEST}/compiler.txt
819 if [ -e "/lib/libc.so.6" ]; then
820 echo '</TD></TR><TR><TD>Library Version</TD><TD>/lib/libc.so.6</TD></TR>'
821 echo '<TR><TD colspan="2"><PRE>'
823 /lib/libc.so.6 | sed -e 's/</\&lt;/g' -e 's/>/\&gt;/g'
826 echo '</PRE></TD></TR></TBODY></TABLE>'
827 echo '</body></html>'
830 ###############################################################################
832 # create_page
834 ###############################################################################
835 create_page ()
837 # always strip off "ACE___" / "TAO___" / "CIAO___"
838 local BASE=$1
839 local TYPE=$2
840 local EXT=""
841 local BASE_NAME=${BASE#ACE___}
842 local BASE_NAME=${BASE#TAO___}
843 local BASE_NAME=${BASE#CIAO___}
844 local BASE_NAME=${BASE#DAnCE___}
845 local TITLE="${TYPE} metrics for ${BASE_NAME//___//}"
847 if [ "$TYPE" = "Compilation" ]; then
848 EXT="txt"
849 UNITS="100th's of seconds"
850 else
851 EXT="size"
852 UNITS="Bytes"
855 # header
856 echo "<html>"
857 echo "<head><title>$TITLE</title></head>"
858 echo '<style><!--'
859 echo 'body,td,a,p,.h{font-family:arial,sans-serif;}'
860 echo '.h{font-size: 20px;}'
861 echo '.q{text-decoration:none; color:#0000cc;}'
862 echo '//-->'
863 echo '</style>'
864 echo '<body text = "#000000" link="#000fff" vlink="#ff0f0f" bgcolor="#ffffff">'
865 echo "<br><center><h1>$TITLE</h1></center><br>"
866 if [ -e "${DEST}/images/${BASE}_${TYPE}.png" ]; then
867 echo '<DIV align="center"><P>'
868 echo "<IMG alt=\"$BASE\" border=0 src=\"images/${BASE}_${TYPE}.png\""
869 echo 'width="800" height="600"></P></DIV>'
872 echo "<br><hr><br>"
873 echo "<center><h2>Detail (${DATE})</h2></center>"
875 echo '<TABLE border="2"><TBODY><TR><TD rowspan=2><b>Object</b></TD>'
876 echo '<TD colspan="4" align=center><b>Last Compile</b></TD></TR>'
877 echo "<TR><TD align=center><b>Date</b></TD><TD align=center><b>$UNITS</b></TD>"
878 echo '<TD align=center><b>%chg</b></TD><TD align=center><b>Data</b></TD></TR>'
879 while read i; do
880 if [ -e "${DEST}/data/${i}.${EXT}" ]; then
881 LAST=0 PRE=0 VAL_TMP=0 VAL_INT=0 VAL_SIGN="+"
882 echo '<TR><TD>'
883 if [ -e "${DEST}/${i}_${TYPE}.html" ]; then
884 # strip off "ACE___" if it exists
885 NAME=${i#ACE___}
886 # strip off "TAO___" if it exists
887 NAME=${i#TAO___}
888 # strip off "CIAO___" if it exists
889 NAME=${i#CIAO___}
890 # strip off "DAnCE___" if it exists
891 NAME=${i#DAnCE___}
892 echo "<a href=\"${i}_${TYPE}.html\">${NAME//___//}</a>"
893 elif [ -e "${DEST}/images/${i}_${TYPE}.png" ]; then
894 # since you'll only have images if it's a composite, strip off the
895 # path for the name
896 if [ "$TYPE" = "Footprint" ]; then
897 # if we are doing footprint, add library
898 llib=`grep -e "lib.*\.a" ${DEST}/size_composites.txt | grep ${i} | awk '{print $1}'`
899 #echo "lib $llib"
900 #llib="${llib% :}"
901 llib="${llib//___//}"
902 NAME="${llib}(${i##*___})"
903 else
904 NAME="${i##*___}"
906 echo "<a href=\"images/${i}_${TYPE}.png\">${NAME}</a>"
907 else
908 echo "${i##*___}"
910 echo '</TD><TD>'
911 echo `sort -t'/' -k1n -k2n -k3n ${DEST}/data/${i}.${EXT} | grep -E ^2 | tail -n1 | cut -d" " -f1`
912 let LAST=`sort -t'/' -k1n -k2n -k3n ${DEST}/data/${i}.${EXT} | grep -E ^2 | tail -n1 | cut -d" " -f2`
913 echo "</TD><TD align=right>$LAST</TD>"
914 let PRE=`sort -t'/' -k1n -k2n -k3n ${DEST}/data/${i}.${EXT} | grep -E ^2 | tail -n2 | head -n1 | cut -d" " -f2`
915 let VAL_TMP="((($LAST+1)-($PRE+1))*1000)/($PRE+1)"
916 if [ $VAL_TMP -lt 0 ]; then
917 VAL_SIGN="-"
918 let VAL_TMP="-1*$VAL_TMP"
919 elif [ $VAL_TMP -eq 0 ]; then
920 VAL_SIGN=
922 let VAL_INT="$VAL_TMP/10"
923 let VAL_TENTH="$VAL_TMP-($VAL_INT*10)"
924 echo "<TD align=right>${VAL_SIGN}${VAL_INT}.${VAL_TENTH}</TD>"
925 echo "<TD align=right><a href=\"data/${i}.${EXT}\">Data</a></TD>"
926 echo "</TR>"
927 else
928 echo '<TR><TD>'
929 echo "${i}"
930 echo '</TD><TD>'
931 echo '?'
932 echo "</TD><TD align=right>?</TD>"
933 echo "<TD align=right>?</TD><TD align=right>?</TD></TR>"
935 done # for
936 echo '</TBODY></TABLE>'
938 # footer
939 echo '</body></html>'
943 ###############################################################################
945 # sort_list
947 ###############################################################################
948 sort_list ()
950 # sort the dependency files
951 if [ -e ${DEST}/tmp_list ]; then
952 rm ${DEST}/tmp_list
955 touch ${DEST}/tmp_list
956 for i in $@; do
957 echo "$i" >> ${DEST}/tmp_list
958 #echo $i
959 done
961 sort -f ${DEST}/tmp_list
964 ###############################################################################
966 # create_html
968 ###############################################################################
969 create_html ()
971 echo "create_html()"
973 local DEST=$1
974 local TYPE=$2
975 local ALL_OBJS=""
976 local ACE_OBJS=""
977 local TAO_OBJS=""
978 local CIAO_OBJS=""
979 local DAnCE_OBJS=""
981 while read base colon files; do
982 # create individual page for app/lib
984 sort_list ${files} | create_page ${base} ${TYPE} \
985 > ${DEST}/${base}_${TYPE}.html
986 if [ "${base}" != "${base#DAnCE}" ]; then
987 DAnCE_OBJS="${DAnCE_OBJS} ${base}"
988 elif [ "${base}" != "${base#CIAO}" ]; then
989 CIAO_OBJS="${CIAO_OBJS} ${base}"
990 elif [ "${base}" != "${base#TAO}" ]; then
991 TAO_OBJS="${TAO_OBJS} ${base}"
992 elif [ "${base}" != "${base#ACE}" ]; then
993 ACE_OBJS="${ACE_OBJS} ${base}"
995 ALL_OBJS="${ALL_OBJS} ${base}"
996 done
998 # create main page
999 create_index_page ${TYPE} > ${DEST}/index.html
1001 if [ "${TYPE}" = "Compilation" ] || [ "${TYPE}" = "Footprint" ]; then
1002 if [ $BASE_TITLE = $DEFAULT_TITLE ]; then
1003 name="ace_${TYPE}.html"
1004 sort_list ${ACE_OBJS} | create_page "ACE" ${TYPE} > ${DEST}/${name}
1006 name="tao_${TYPE}.html"
1007 sort_list ${TAO_OBJS} | create_page "TAO" ${TYPE} > ${DEST}/${name}
1009 name="ciao_${TYPE}.html"
1010 sort_list ${CIAO_OBJS} | create_page "CIAO" ${TYPE} > ${DEST}/${name}
1012 name="dance_${TYPE}.html"
1013 sort_list ${DAnCE_OBJS} | create_page "DAnCE" ${TYPE} > ${DEST}/${name}
1014 else
1015 name="all_${TYPE}.html"
1016 sort_list ${ALL_OBJS} | create_page $BASE_TITLE ${TYPE} > ${DEST}/${name}
1021 ###############################################################################
1023 # main program
1025 ###############################################################################
1027 INFILE=""
1028 DEST=""
1029 TARGETS=""
1030 DATE=""
1031 METRIC="Compilation"
1032 FUDGE_FACTOR=0
1033 BASE_ROOT=$ACE_ROOT
1034 DEFAULT_TITLE=ACE+TAO+CIAO+DAnCE
1035 BASE_TITLE=$DEFAULT_TITLE
1036 COMPILER="gcc"
1038 parse $@
1039 create_dirs "${DEST}/"
1040 create_dirs "${DEST}/"
1042 if [ "$METRIC" = "Compilation" ]; then
1044 ########################################################
1045 # compile times
1047 # grab the compile time metrics for objects only and process them
1048 grep "compile time(0):" $INFILE | grep "\.o" | cut -d' ' -f3,4,5 | process_file
1050 # Create ${DEST}/composites.txt with entries like this:
1051 # tests___OS_Test : tests___OS_Test.o tests___Main.o
1052 create_composite_list $TARGETS
1054 # compile times
1055 cat ${DEST}/composites.txt | rollup_compile_times
1056 find ${DEST}/data/ -name "*.txt" | create_images ${DEST} "Compilation"
1057 cat ${DEST}/composites.txt | create_html ${DEST} "Compilation"
1059 elif [ "$METRIC" = "Footprint" ]; then
1061 ########################################################
1062 # footprint
1064 # Create ${DEST}/libraries.txt with entries like this:
1065 # ace___libACE.a
1066 create_library_list $TARGETS
1068 # Create ${DEST}/composites.txt with entries like this:
1069 # tests___OS_Test : tests___OS_Test.o tests___Main.o
1070 create_composite_list $TARGETS
1072 # Run size on the executables and append results to *.size file.
1073 cat ${DEST}/composites.txt | footprint
1075 # Run size on the libraries and append results to *.size for the
1076 # library and each contained object.
1077 # It also creates ${DEST}/size_composites.txt based on size output for
1078 # libraries with entries like this:
1079 # ace___libACE.a : ace___ACE.o ace___Addr.o
1080 cat ${DEST}/libraries.txt | footprint LIB
1082 # Add executables to ${DEST}/size_composites.txt based on output
1083 # from the map files (created with LDFLAGS=-Xlinker -M -Xlinker
1084 # -Map -Xlinker $(@).map). Find the map files of we want based on
1085 # entries in ${DEST}/composites.txt.
1086 cat ${DEST}/composites.txt | create_size_composites
1088 find ${DEST}/data/ -name "*.size" | create_images ${DEST} "Footprint"
1089 cat ${DEST}/size_composites.txt | create_html ${DEST} "Footprint"
1091 else
1092 echo "metric type ($METRIC) not recognized"
1093 usage