Yes, but the point of a test is to come to a decision, in this case, Should I use a scan or a dowhile loop for best speed?
And the answer is: It depends...
Greg
-----Original Message----- From: Wilson M. Kierstead [mailto:wil .at. vfpbizapps D.O.T com]=20 Sent: Friday, January 31, 2003 1:13 PM To: profox@leafe.com Subject: RE: is this a fair test? (SCAN vs DO WHILE)
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 =3D 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 =3D 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 Greg Gum |