Stata 15 help for timer

[P] timer -- Time sections of code by recording and reporting time spent

Syntax

Reset timers to zero

timer clear [#]

Turn a timer on

timer on #

Turn a timer off

timer off #

List the timings

timer list [#]

where # is an integer, 1 through 100.

Description

timer starts, stops, and reports up to 100 interval timers. Results are reported in 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, which causes the timer to accumulate.

timer list lists the timings. If # is not specified, timers that contain zero 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

Stored results

timer list stores the following in r():

Scalars r(t1) value of first timer r(nt1) # of times turned on and off

r(t2) value of second timer r(nt2) # of times turned on and off

. . .

r(t100) value of 100th timer r(nt100) # of times turned on and off

Only values for which r(nt#)!=0 are stored.

r() results produced by other commands are not cleared.


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