Professional Documents
Culture Documents
Ss
Ss
tcl - gives the CPU time consumed since the last stopwatch
# chrispy@synopsys.com
#
# v1.0 09/14/1999
# initial release
# v1.1 10/13/1999
# added support for memory
# v1.2 1/22/2004
# use namespaces to save previous cputime/mem values
# v1.3 2/10/2004
# fix harmless bug in namespaces
# when we run for the first time, just because we declared variables
# in our namespace above, doesn't mean that they actually exist yet;
# this is why we can use this check to know if it was the first time
# we've been invoked
if {[info exists stopwatch::last_cputime]} {
echo "Information: Time used since last stopwatch is [expr [cputime] -
$stopwatch::last_cputime]. $infomsg"
echo "Information: Memory used since last stopwatch is [expr [mem] -
$stopwatch::last_mem]k. $infomsg"
} else {
echo "Information: Time used since beginning of process is [cputime]. $infomsg"
echo "Information: Memory used since beginning of process is [mem]k. $infomsg"
}
redirect $sh_dev_null {set stopwatch::last_cputime [cputime]}
redirect $sh_dev_null {set stopwatch::last_mem [mem]}
}
define_proc_attributes stopwatch \
-info "gives CPU time/memory consumed since the last stopwatch" \
-define_args \
{
{ info "optional info message" "info" string optional }
}