I am very glad to know this is now available. In the old days, when I
used a VAX machine and submitted jobs to a queue, I had to estimate how
long the job would take so I could send the job to the appropriate queue
(mis-estimations would make the job crash in the middle if I sent a long
job to a short queue). In those days the output file would list at
various points in a job how long various tasks took. Some software now
does this as well automatically, but as far as I know the software that
does this seems to be software that has a strong legacy from the old days
(pre-1990). If one is running short jobs it may not be a big issue. But
my jobs often run for several days, so it can really help to be able to
put timers on various segments to see what commands are slowing things
down more than others. This will be useful for planning work and
estimating length of time for future jobs, and there are other advantages
as well. I know I could check interactively with the unix command tail
and the name of the output file, and that is what I have generally done in
the past, but it is far better to have the timings recorded in the file
for posterity or, more humbly, my use when I need it.
So I say a wholehearted "Thanks" for information about this command.
Sam
On Wed, 17 May 2006, William Gould, Stata wrote:
> Joseph Coveney <[email protected]> asked,
>
> > Does anyone know what -timer- does or how to use it?
> >
> > . which timer
> > built-in command: timer
> >
> > It wasn't there this February when I wrote my own little -timer.ado- to
> > convert SAS's seconds-from-midnight into a Stata string (hh:mm:ss) for a
> > project that's ongoing in fits and starts, so it's new since Release 9.2
> > (Windows).
>
> We apolgize to Joseph for breaking his -timer.ado-.
>
> -timer- is an profiling tool we use internally at StataCorp and never deserved
> such a good name. In fact, -timer- has been in the Linux version of Stata
> since about Stata 8 and just recently, as Joseph notes, was put into all
> versions of Stata, because we were using it to test Stata/MP.
> We should have renamed it when we did that.
>
> The damage is now done.
>
> We will add an "undocumented" help file for -timer-. In the meantime,
> documentation can be found below.
>
>
> Title
> -----
>
> timer -- Profiling tool
>
>
> Syntax
> ------
>
> timer clear [#]
> timer on #
> timer off #
> timer list [#]
>
> where # is an integer, 1 <= # <= 100
>
>
> Description
> -----------
>
> The -timer- command starts, stops, and reports up to 100 interval timers.
> Results are reported in units of seconds.
>
> -timer clear- resets timers to zero.
>
> -timer on- begins a timing. -timer off- stops a timing. A timing may be
> turned on and off repeatedly without clearing and the timer then
> accumulates.
>
> -timer list- lists the timings. If # is not specified, timers that
> contain 0 are not listed.
>
>
> Remarks
> -------
>
> -timer- can be used to time sections of code. For instance,
>
> program tester
> version ...
>
> timer clear 1
> forvalues repeat=1(1)100 {
> timer on 1
> mycmd ....
> timer off 1
> }
> timer list 1
> end
>
>
> Saved results
> -------------
>
> -timer list- saves in r()
>
> r(t1) value of 1st timer
> r(t2) value of 2nd timer
> ...
> r(t100) value of 100th timer
>
> If r(t#)==0, its value is not saved. r() is *NOT* cleared by
> -timer list-, so as not to interfere with saved results by the
> program being timed.
>
>
> -- Bill -- Vince -- Hua
> [email protected] [email protected] [email protected]
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/