Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: -timer-

From (William Gould, Stata)
Subject   Re: st: -timer-
Date   Wed, 17 May 2006 09:21:57 -0500

Joseph Coveney <> 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.


        timer -- Profiling tool


        timer clear [#]
        timer on     #
        timer off    #
        timer list  [#]

    where # is an integer, 1 <= # <= 100


    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

    -timer list- lists the timings.  If # is not specified, timers that
    contain 0 are not listed.


     -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

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
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index