#! /bin/sh # # This script generate metrics html pages for either compile times or # footprint. # # Compile times: # Parse the build.txt file from an autobuild that was generated with the # g++_metric.sh script, e.g., with CXX=g++_metric.sh which outputs # compile times on a per object basis, and use the data to generate time # series graphs with gnuplot. # # Footprint: # Parse the build.txt file and and the *.map files, generated with LDFLAGS # set to =-Xlinker -M -Xlinker -Map -Xlinker \$@.map and static_libs_only=1. # # For use with an autobuild, place a line something like this in the xml file, # after the log file is closed, but before it's moved. # # # ############################################################################### # # usage # ############################################################################### usage () { echo "Usage: `basename $0` [--base=] [--name=] [--compiler=compiler]" echo " [target_file]" echo " [Footprint|Compilation] [] []" echo "" echo "--base This option can be used to set the base root directory to" echo " something other than the default \$ACE_ROOT." echo "--name This option can be used to set the software title to something" echo " other than the default ACE+TAO." echo "--compiler This option can be used to set the compiler to something" echo " other than the default gcc." echo "input_file This is the compilation log file." echo "destination_directory This designates the location of the generated html." echo "target_file This is similar to input_file, but should contain no errors." echo "date Set the date used in all generated html pages." echo "fudge_factor Add the specified number of seconds to the compilation time" echo " for each target." echo "" echo "Options must be specified in the order shown above." exit } ############################################################################### # # parse_time # # this only works for english # assumes the date is formatted like this: Sat Apr 12 18:19:31 UTC 2003 # and outputs this: 2003/04/12-18:19 # ############################################################################### parse_time () { # todo: add a format parameter local INDEX=0 local PT_MONTH="" local PT_DAY="" local PT_YEAR="" local PT_HOUR="" local PT_MINUTE="" local PT_SECOND="" local PT_TIMEZONE="" read -a line for token in "${line[@]}"; do #echo "$INDEX = $token" case $INDEX in 1 ) case $token in Jan ) PT_MONTH="01" ;; Feb ) PT_MONTH="02" ;; Mar ) PT_MONTH="03" ;; Apr ) PT_MONTH="04" ;; May ) PT_MONTH="05" ;; Jun ) PT_MONTH="06" ;; Jul ) PT_MONTH="07" ;; Aug ) PT_MONTH="08" ;; Sep ) PT_MONTH="09" ;; Oct ) PT_MONTH="10" ;; Nov ) PT_MONTH="11" ;; Dec ) PT_MONTH="12" ;; esac ;; 2 ) PT_DAY="$token" ;; 3 ) PT_HOUR="${token%%:*}" PT_MINUTE="${token%:*}" PT_MINUTE="${PT_MINUTE#*:}" PT_SECOND="${token##*:}" ;; 4 ) PT_TIMEZONE="$token" ;; 5 ) PT_YEAR="$token" ;; esac let INDEX=$INDEX+1 done if [ "$1" = "debug" ]; then echo "month = $PT_MONTH" echo "day = $PT_DAY" echo "year = $PT_YEAR" echo "hour = $PT_HOUR" echo "min = $PT_MINUTE" echo "sec = $PT_SECOND" echo "tz = $PT_TIMEZONE" fi echo "$PT_YEAR/$PT_MONTH/$PT_DAY-$PT_HOUR:$PT_MINUTE" } ############################################################################### # # strip_date # # grab date from line with following format: # ################### End [Fri Apr 11 00:18:31 2003 UTC] # and return it in this format: Fri Apr 11 00:18:31 UTC 2003 which is # what parse_time() expects # ############################################################################### strip_date () { local INDEX=0 local TEMP_DATE="" local DATE="" read -a line for token in "${line[@]}"; do #echo "$INDEX = $token" case $INDEX in 2 ) DATE=${token#[} ;; 7 ) DATE="$DATE ${token%]} $TEMP_DATE" ;; # this is a hack since the autobuild scripts don't format the date # correctly... :-( 6 ) TEMP_DATE=$token ;; * ) DATE="$DATE $token" ;; esac let INDEX=$INDEX+1 done echo $DATE } ############################################################################### # # parse # # Parse the commandline and validate the inputs # ############################################################################### parse () { echo "parse()" while [ $# -gt 1 ]; do if [ -n "`echo $1 | grep '^--base=.*'`" ]; then BASE_ROOT=`echo $1 | sed 's/^--base=//'` shift elif [ -n "`echo $1 | grep '^--name=.*'`" ]; then BASE_TITLE=`echo $1 | sed 's/^--name=//'` shift elif [ -n "`echo $1 | grep '^--compiler.*'`" ]; then COMPILER=`echo $1 | sed 's/^--compiler=//'` shift else break fi done # set input file and destination (required) if [ $# -gt 1 ]; then INFILE=$1 DEST=$2 if ! [ -e "$INFILE" ]; then echo "input_file $INFILE does not exist." usage fi else usage fi # set the target file from command line if [ $# -gt 2 ]; then TARGETS=$3 else TARGETS=$INFILE fi # set type of metric from command line if [ $# -gt 3 ]; then METRIC=$4 else METRIC="Compilation" fi echo "metric = ($METRIC)" # set the date from command line if [ $# -gt 4 ]; then DATE=$5 else DATE=`tail -n 1 $INFILE | strip_date | parse_time` fi echo "date = ($DATE)" # set fudge factor from commandline (for testing) if [ $# -gt 5 ]; then FUDGE_FACTOR=$6 else FUDGE_FACTOR=0 fi } ############################################################################### # # gen_chart # # Generate the actual charts and move them to ${DEST} # ############################################################################### gen_chart () { local object=$1 local DEST=$2 local TYPE=$3 local EXT="txt" local YLABEL="Compile Time (Seconds)" local FACTOR=1 local low=$4 local high=$5 if [ "$TYPE" = "Footprint" ]; then EXT="size" if [ ${high} -gt 1024 ]; then YLABEL="Footprint (KBytes)" FACTOR=1024 else YLABEL="Footprint (Bytes)" FACTOR=1 fi fi let low="${low}/${FACTOR}" let high="${high}/${FACTOR}" sort -t'/' -k1n -k2n -k3n ${DEST}/data/${object}.${EXT} | grep -E ^2 > tmp.txt gnuplot <