diff options
author | David Williams | 2016-05-08 17:07:01 +0000 |
---|---|---|
committer | David Williams | 2016-05-08 17:07:01 +0000 |
commit | e2772ca94b666b2c2bcb153b3ebdfcf448ef4ae1 (patch) | |
tree | 7aa65e72362455d09718a14bc199391a933c16f7 /production/bashUtilities.shsource | |
parent | 0cbe61971ca2eb55bca2d8b55b6fe7923cad6ea5 (diff) | |
download | eclipse.platform.releng.aggregator-e2772ca94b666b2c2bcb153b3ebdfcf448ef4ae1.tar.gz eclipse.platform.releng.aggregator-e2772ca94b666b2c2bcb153b3ebdfcf448ef4ae1.tar.xz eclipse.platform.releng.aggregator-e2772ca94b666b2c2bcb153b3ebdfcf448ef4ae1.zip |
[releng] Begin adding elapsed time to build steps
Diffstat (limited to 'production/bashUtilities.shsource')
-rw-r--r-- | production/bashUtilities.shsource | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/production/bashUtilities.shsource b/production/bashUtilities.shsource index ad30df2a9..a5b8750f4 100644 --- a/production/bashUtilities.shsource +++ b/production/bashUtilities.shsource @@ -133,3 +133,93 @@ assertNotEmpty () } + +function show_time () { +num=$1 +min=0 +hour=0 +day=0 +if((num>59));then + ((sec=num%60)) + ((num=num/60)) + if((num>59));then + ((min=num%60)) + ((num=num/60)) + if((num>23));then + ((hour=num%24)) + ((day=num/24)) + else + ((hour=num)) + fi + else + ((min=num)) + fi +else + ((sec=num)) +fi + +if [[ $day > 0 ]] +then + echo "$day d $hour h $min m $sec s" +elif [[ $hour > 0 ]] +then + echo "$hour h $min m $sec s" +elif [[ $min > 0 ]] +then + echo "$min m $sec s" +else + echo "$sec s" +fi +} + +# This funtion needs three arguments, in order. +# StartTime (in epoch seconds) +# EndTime (in epock seconds) +# Message. Optional quoted string that is printed with elapsed time. If not provided, "Elapsed Time" is used. +# +elapsedTime () +{ + start=$1 + end=$2 + message=$3 + # TODO: could improve error checking, by making sure times are "all digits" + if [[ -z "$start" ]] + then + "[ERROR] Start time must be provided to ${0##/}" + exit 1 + fi + if [[ -z "$end" ]] + then + "[ERROR] End time must be provided to ${0##/}" + exit 1 + fi + if [[ -z "$message" ]] + then + message="Elapsed Time" + fi + elapsedSeconds=$(( ${end} - ${start} )) + elapsedTime=$( show_time $elapsedSeconds ) + echo -e "\n\t${message}: $elapsedTime" + if [[ -n "${timeFile}" ]] + then + echo -e "\n\t${message}: $elapsedTime\n\t\t\tRawSeconds: ${elapsedSeconds}" >> "${timeFile}" + fi +} + +testElapsedTime () +{ + #RAW_DATE_START="$(date -u +%s )" + RAW_DATE_START="$(date +%s )" + + echo -e "\n\tRAW Date Start: ${RAW_DATE_START} \n" + echo -e "\tStart Time: $( date +%Y%m%d%H%M%S -d @${RAW_DATE_START} )" + + sleep 6 + + RAW_DATE_END="$(date +%s )" + + echo -e "\n\tRAW Date End: ${RAW_DATE_END} \n" + echo -e "\tEnd Time: $( date +%Y%m%d%H%M%S -d @${RAW_DATE_END} )" + + elapsedTime $RAW_DATE_START $RAW_DATE_END "Testing Elapsed Time" +} |