Re: Trying to do a simple time command for procs...can't get output into console...



At 2007-04-27 06:10PM, "daneyul" wrote:

Hi,

Does anyone have a good generic method of easily timing every proc in
an application for diagnostics? Something that can be turned on and
off at will by simply redefining the proc command? I'm trying from a
freewrapped app, using the following at the beginning of the script,
but I'm failing miserably...

proc TimeProcs {} {
console show

In case you're using this proc outside of Tk:
catch {console show}

rename ::proc ::proc2
::proc2 ::proc {name vars body} {
::proc2 $name $vars "time {$body}"
}

After some experimentation, I came up with:
::proc2 ::proc {name vars body} {
::proc2 $name $vars [format {puts [time {%s}]} $body]
}

Testing:
% proc test {} {for {set i 0} {$i < 5} {incr i} {puts $i; after 1000}}
% test
0
1
2
3
4
5073353 microseconds per iteration

--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
.



Relevant Pages