[clock] behaves just slow (Re: [clock scan] behaves inconsistently in Tcl8.5 (was: Re: [clock scan day] behaves differentyl in Tcl8.5 than in Tcl8.4))



On Mon, 29 Aug 2005, Don Porter wrote:

the new [clock add] command that's the recommended way to do things like above with Tcl 8.5.

The old way:

# tclsh8.4
% time {clock seconds} 1000
84 microseconds per iteration
% time {clock scan "+1 day"} 1000
858 microseconds per iteration
% time {clock format [clock scan "+1 day"]} 1000
1571 microseconds per iteration
% info patchlevel
8.4.9

The recommended way (yes, counter is 100 instead of 1000, I'm not in a hurry, but wanted this done today):

# tclsh8.5
% time {clock seconds} 100
475.35 microseconds per iteration
% time {clock add [clock seconds] +1 day} 100
40774.31 microseconds per iteration
% time {clock format [clock add [clock seconds] +1 day]} 100
117802.13 microseconds per iteration
% info patchlevel
8.5a3

I have expressed my longing for old days before, just making a note here. Please optimize, my application is running at 5% CPU when doing nothing but ticking seconds (feel sorry for my vintage hardware :)

If nothing else, can [clock add] obtain [clock seconds] somehow in more direct manner, [clock [clock [clock ...]]] just makes me feel dizzy and wait for the cuckoo.

--
-Kaitzschu
s="TCL ";while true;do echo -en "\r$s";s=${s:1:${#s}}${s:0:1};sleep .1;done
.



Relevant Pages