-
Bug
-
Resolution: Fixed
-
P4
-
6
-
b63
-
generic
-
generic
The following ksh script will return the wall-clock time used in a very short string "NNhNNm", e.g. 1h3m or 4m. If we could incorporate this into the j2se makefiles define of SUBDIRS-loop, we could add the time spent in each makefile recursion.
Also we could create a name for each recursion like "TOP->java->java_hprof_demo" by doing something like TIMER_NAME:=$(TIMER_NAME)->$${i} inside the for loop.
Finally, these strings should be kept in a timer_logfile for later processing when the build has completed, so we can create a report at the end as to how long various parts of the build took, maybe list the top 10 time consuming parts?
> cat /home/ohair/bin/timer
#!/bin/ksh
##################################################################
# Get a time cookie that will work for this logic
time_cookie()
{
date +%j:%H:%M
}
# Given a time cookie, return a total minutes number
time_to_total_minutes()
{
if [ "$1" != "" ] ; then
# Windows MKS expr has problems with 008, (leading 0 problem)
days=$(echo $1 | cut -d':' -f1 | sed -e 's@^0*@@')
if [ "${days}" = "" ] ; then
days=0
fi
hours=$(echo $1 | cut -d':' -f2 | sed -e 's@^0*@@')
if [ "${hours}" = "" ] ; then
hours=0
fi
minutes=$(echo $1 | cut -d':' -f3 | sed -e 's@^0*@@')
if [ "${minutes}" = "" ] ; then
minutes=0
fi
total_minutes=$(expr ${days} '*' 60 '*' 24 '+' ${hours} '*' 60 '+' ${minutes})
else
total_minutes=0
fi
}
# Given two time cookies, echos out a short time used, e.g. 4m, or 5h6m
time_used() # start_time end_time
{
_start_time=$1
time_to_total_minutes ${_start_time}
_start_mins=${total_minutes}
_end_time=$2
time_to_total_minutes ${_end_time}
_end_minutes=${total_minutes}
_total_minutes_used=$(expr ${_end_minutes} '-' ${_start_mins})
_hours_used=$(expr ${_total_minutes_used} '/' 60)
_minutes_used_in_last_hour=$(expr ${_total_minutes_used} '%' 60)
if [ ${_hours_used} -eq 0 ] ; then
_time_used=${_minutes_used_in_last_hour}m
else
_time_used=${_hours_used}h${_minutes_used_in_last_hour}m
fi
echo "${_time_used}"
}
# Example usage
start_time=$(time_cookie)
eval $*
end_time=$(time_cookie)
echo "Timer says this took: $(time_used ${start_time} ${end_time})"
exit 0
Also we could create a name for each recursion like "TOP->java->java_hprof_demo" by doing something like TIMER_NAME:=$(TIMER_NAME)->$${i} inside the for loop.
Finally, these strings should be kept in a timer_logfile for later processing when the build has completed, so we can create a report at the end as to how long various parts of the build took, maybe list the top 10 time consuming parts?
> cat /home/ohair/bin/timer
#!/bin/ksh
##################################################################
# Get a time cookie that will work for this logic
time_cookie()
{
date +%j:%H:%M
}
# Given a time cookie, return a total minutes number
time_to_total_minutes()
{
if [ "$1" != "" ] ; then
# Windows MKS expr has problems with 008, (leading 0 problem)
days=$(echo $1 | cut -d':' -f1 | sed -e 's@^0*@@')
if [ "${days}" = "" ] ; then
days=0
fi
hours=$(echo $1 | cut -d':' -f2 | sed -e 's@^0*@@')
if [ "${hours}" = "" ] ; then
hours=0
fi
minutes=$(echo $1 | cut -d':' -f3 | sed -e 's@^0*@@')
if [ "${minutes}" = "" ] ; then
minutes=0
fi
total_minutes=$(expr ${days} '*' 60 '*' 24 '+' ${hours} '*' 60 '+' ${minutes})
else
total_minutes=0
fi
}
# Given two time cookies, echos out a short time used, e.g. 4m, or 5h6m
time_used() # start_time end_time
{
_start_time=$1
time_to_total_minutes ${_start_time}
_start_mins=${total_minutes}
_end_time=$2
time_to_total_minutes ${_end_time}
_end_minutes=${total_minutes}
_total_minutes_used=$(expr ${_end_minutes} '-' ${_start_mins})
_hours_used=$(expr ${_total_minutes_used} '/' 60)
_minutes_used_in_last_hour=$(expr ${_total_minutes_used} '%' 60)
if [ ${_hours_used} -eq 0 ] ; then
_time_used=${_minutes_used_in_last_hour}m
else
_time_used=${_hours_used}h${_minutes_used_in_last_hour}m
fi
echo "${_time_used}"
}
# Example usage
start_time=$(time_cookie)
eval $*
end_time=$(time_cookie)
echo "Timer says this took: $(time_used ${start_time} ${end_time})"
exit 0