Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: CPU usage for Stata loops (Windows)


From   Nick Winter <[email protected]>
To   Stata List <[email protected]>
Subject   st: CPU usage for Stata loops (Windows)
Date   Fri, 06 Nov 2009 11:18:36 -0500

Hi,

On my Windows XP [fully up to date, legal IC Stata 11 :-) ], the following consumes 30-50% of my system CPU time, according to the Windows Task Manager:

while 1 {
  sleep 500
}

Whereas this consumes essentially 0 CPU time:

while 1 {
  sleep 501
}


(On one computer the first loop consumes 50%, i.e. the total that Stata can use on my Dual Core processor; on a different computer it takes "only" 30-ish percent. But on both systems there's a sharp drop to essentially nothing in the second loop.

Any ideas why?


An aside on why I care:

I'm writing a program in which Stata calls an external program and waits for it to finish before continuing. I'd like to handle this with -winexec- followed by watching for the creation of a file by the external program to signal that it's done, rather than using 'shell' to make Stata wait, because I want Stata to spawn several of these processes and then wait for them *all* to finish.

So my strategy is to do something like this:

	winexec "c:\usrdata\autoit\sttest.exe"
	sleep 500
	capture confirm file "c:\temp\xxx.txt"
	while _rc {
		sleep 500
		capture confirm file "c:\temp\xxx.txt"
	}
	di "done!!!"


- Nick Winter


--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  [email protected] e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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