Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: time elapsed within 'for' loops


From   Mark Schaffer <M.E.Schaffer@hw.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: time elapsed within 'for' loops
Date   Sun, 14 Nov 2004 11:09:58 +0000 (GMT)

Dave,

Try -profiler-; it will probably do what you want.  From the help file:

"profiler is a programmer's command that can help in optimizing ado-files
and other Stata programs.  When profiling is turned on, profiler on, Stata
begins keeping a record of each time a program is run and how much time is
spent in the program."

Hope this helps.

--Mark

BTW, when start a session with -profiler clear- and I haven't run profiler
yet, it crashes.  Just -capture profiler clear- is the way I deal with it.

On Sun, 14 Nov 2004 05:54:58 -0500 (EST), David K Evans
<dkevans@fas.harvard.edu> wrote:

> Stata friends,
> 
> Is there a simple way to see how much time has elapsed while a
> command in the midst of a "for" loop is running?
> 
> Outside of a loop, I just "set rmsg on" and can see how long each
> command takes.
> 
> But if I have, for example,
> 
> for num 1/10: preserve \ keep if age==X \ reshape [blah blah blah]
> \
> save ageX.dta, replace \ restore;
> 
> and I want to know how long the reshaping took, I'm not sure how to
> find out. "set rmsg on" only gives me the time for the entire loop.
> 
> I know about macros to display the time, but I'm not sure how to
> manipulate them to calculate time elapsed.
> 
> Thanks so much,
> Dave
> 
> ------------------------------------------------------------------------
> 
> PhD student, Harvard Economics Department
> Phone: (O) 617-495-5634, (H) 617 - 493 - 1536
> Address: Currier Mail Center #554, Cambridge, MA 02138
> 
> ------------------------------------------------------------------------
> *
> *   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/
> 



Prof. Mark Schaffer
Director, CERT
Department of Economics
School of Management & Languages
Heriot-Watt University, Edinburgh EH14 4AS
tel +44-131-451-3494 / fax +44-131-451-3008
email: m.e.schaffer@hw.ac.uk
web: http://www.sml.hw.ac.uk/ecomes
________________________________________________________________

DISCLAIMER:

This e-mail and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to
whom it is addressed.  If you are not the intended recipient
you are prohibited from using any of the information contained
in this e-mail.  In such a case, please destroy all copies in
your possession and notify the sender by reply e-mail.  Heriot
Watt University does not accept liability or responsibility
for changes made to this e-mail after it was sent, or for
viruses transmitted through this e-mail.  Opinions, comments,
conclusions and other information in this e-mail that do not
relate to the official business of Heriot Watt University are
not endorsed by it.
________________________________________________________________
*
*   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/



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