-------------------------------------------------------------------------------
help for etime                                                manual:  [R] none
                                                             dialog:   none    
-------------------------------------------------------------------------------

Time how long a program runs; or, simply, keep track of the elapsed time from p > oint A to point B in a program

etime [ , start} datestart(start date) timestart(start time) ]

Description

etime is designed for programmers who want to keep track of how long a program takes to run. Using Stata's creturn variables: c(current_date) and c(current_time), etime clocks the difference in time between calls. Like a stopwatch, etime needs to be started and stopped. The second and following times etime is submitted it displays a message that says how long it has been since the first time etime was submitted (in the current Stata session).

Options

start specifies to set or reset etime. Not specifying start is equivalent to ending or simply checking the elapsed time.

Options datestart() and timestart() need to be used when timing a command that runs etime or Stata's macro drop _all and sreturn clear

datestart specifies to etime to use this start date. The date must be in the %dD_m_cy format like: 10 Jul 2008 which is the format of c(current_date). If you specify a start date you also have to specify a start time.

timestart specifies to etime to use this start time. The time must be in hr:min:sec format like: 14:20:58 which is the format of c(current_time). If you specify a start time but not the start date, the current date will be used.

Note

etime creates global macros $etime_stardate_ and $etime_startime_

Examples

. etime, start

. etime

Displays:

Elapsed time is 2 hours 27 minutes 3 seconds

If running etime to time a command that uses etime:

. local date `c(current_date)'

. local time `c(current_time)'

. etime, d(`date') t(`time')

. etime, d(10 Jul 2008) t(03:48:14)

Saved Results

The etime command saves in s(): Scalars s(etime) days:hours:mins:secs elapsed since first call to etime s(esecs) total number of seconds elapsed since first call to etime s(stardate) days since Jan. 1, 1960 that etime started s(startime) number of seconds into the day that etime started s(endate) days since Jan. 1, 1960 that etime ended s(endtime) number of seconds into the day that etime ended plus 86,400 seconds for each day since etime started.

Global Macros $etime_stardate_ days since Jan. 1, 1960 that etime started $etime_startime_ number of seconds into the day that etime started

Author

Dan Blanchette The Carolina Population Center University of North Carolina - Chapel Hill, USA dan_blanchette@unc.edu

Also see

On-line: log, datefun, creturn, profiler, rmsg, timer, usagelog (if installed), savasas (if installed), and usesas (if installed)