main logo
Subject: RE: is this a fair test? (SCAN vs DO WHILE)
Author: "Wilson M. Kierstead"
Posted: 2003/01/31 14:31:00
 
View Entire Thread
New Search


It seems you are missing the point. If you are going to do a fair test
against to loop instructions, the criteria has to be the same.

You cannot reasonably compare a DO WHILE with out the check of EOF() against
the SCAN loop. The scan loop intrinsically handles the eof check.
Therefore, an apples to apples test would be as follows:

* Test While loop -Start
SELECT table
ltstart = datetime()
GO TOP
do while !EOF()
skip
enddo
? datetime() - ltstart && show number of seconds taken to skip through
entire table
* Test While loop -End

* Test Scan loop -Start
SELECT table
ltstart = datetime()
SCAN
ENDSCAN
? datetime() - ltstart && show number of seconds taken to skip through
entire table
* Test Scan loop -End

Wilson KIerstead
-----Original Message-----
From: profox-admin AT leafe D.O.T com [mailto:profox-admin@leafe.com]On Behalf Of
profox AT cpvfug D.O.T org
Sent: Friday, January 31, 2003 9:35 AM
To: profox@leafe.com
Subject: RE: is this a fair test? (SCAN vs DO WHILE)


>>> I think what makes it slower is that Fox has to evaluate !EOF() each
time.

Oh yes, I agree 100%. However, I get a laugh when some folks just don't
want to believe it. I've come into apps that took forever and changing to
SCAN loops definitely improved the speed. It was an easy target though:
there were 3 nested DO WHILE !EOF() loops and changing them to scan with
index optimizations really made the difference.

Bo -- I see what you mean now. I changed to SET TALK OFF and the difference
was practically nil.

--Michael

Michael J. Babcock, MCP
Founder/President, Central PA Visual Foxpro User Group (CPVFUG)
Upcoming meetings:
- CHUCK URWILER, February 19, 2003
- DON VAN FLEET (.Net), April 16, 2003
- and more in the works!!!
http://www.cpvfug.org
mbabcock AT cpvfug D.O.T org
"Code smarter, not harder."



[excessive quoting removed by server]



 
©2003 Wilson M. Kierstead
<-- Prior Message New Search Next Message -->