Statalist The Stata Listserver


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

Re: st: tracedepth question


From   Friedrich Huebler <[email protected]>
To   [email protected]
Subject   Re: st: tracedepth question
Date   Mon, 29 Jan 2007 09:10:09 -0800 (PST)

Julian,

To reduce execution time in Windows you can minimize the Stata
window. I don't know if this applies to other operating systems. Try
running the following code once with Stata in the foreground, so that
you can see the output scroll by, and once with Stata minimized.

set more off
set trace on
set rmsg on
forvalues i = 1/10000 {
  di `i'
}

On my computer, executing this code with Stata in the foreground
takes about 50 seconds. If I click the Minimize button in the upper
right corner of the Stata window directly after entering the final
"}", the execution time drops below 4 seconds.

Friedrich

--- Julian Reif <[email protected]> wrote:
> I often write code that contains very long for loops, e.g.
> 
> forval x = 1/100 {
> 	[hundreds of lines of code]
> 	...
> }
> 
> If there is an error somewhere in the loop, Stata reports the error
> type but does not tell me what line it occurred on. To get around
> this, I frequently execute the command -set trace on-, which will
> tell you exactly what line of code the error occurred on. However,
> trace by default steps into each command (and subcommand) called
> inside the loop. This slows down execution and also displays lots
> of information I don't care about.


 
____________________________________________________________________________________
Need a quick answer? Get one in minutes from people who know.
Ask your question on www.Answers.yahoo.com
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index