And in VFP8 I get
scan 0.461 !eof() 0.801
Not bad for a beta<G>
-----Original Message----- From: Crooks, David L. [mailto:croodl (at) ispec DOT com] Sent: Friday, January 31, 2003 3:48 PM To: 'profox@leafe.com' Subject: RE: is this a fair test? (SCAN vs DO WHILE)
In VFP6, I got 0.257 for scan and 0.470 for !EOF().
-----Original Message----- From: Chet Gardiner [mailto:chetdude (at) pacbell DOT net] Sent: Friday, January 31, 2003 3:50 PM To: profox@leafe.com Subject: Re: is this a fair test? (SCAN vs DO WHILE)
Just for grins, I ran it in VFP 7.0 with a couple of changes. Scan was faster.
----------------------------------------------------------------------------
* ScanTest - Modified Scan vs. do while test #define MAXRECS 100000 CLEAR CLEAR ALL CLOSE ALL SET TALK off && Talk OFF - was slowing down Do WHILE LOCAL lnLoop as Integer, lnStartTime as Datetime, lnEndTime as Datetime, lnElapsed as Number
CREATE CURSOR test (name c(10), addr1 c(30), addr2 c(30), city c(20), state c(2), postal c(10))
FOR lnLoop = 1 TO MAXRECS INSERT INTO test VALUES ("Ana Alicia","123 Main St.","","Hamburg","PA","12345-6789") INSERT INTO test VALUES ("Billy Bob","77 Holloway Drive","","West Hollywood","CA","90210-1234") INSERT INTO test VALUES ("Charlie Chaplin","8619 St. Charles Lane","","Mechanicsburg","PA","17712") INSERT INTO test VALUES ("Dee Deserata","777 East Park Blvd","PO Box 777","Harrisburg","PA","17111") INSERT INTO test VALUES ("Mary Poppins","Cantebury","17 Cherry Tree Lane","London","EN","1A1 B5D") ENDFOR
GO TOP IN test SELECT test
*-- DateTime was not granular enough. lnStartSecs = SECONDS() SCAN && scan should be faster than DO WHILE !EOF() ENDSCAN lnEndSecs = SECONDS() lnElapsed = lnEndSecs - lnStartSecs ? "SCAN:",lnStartSecs,lnEndSecs,lnElapsed GO TOP IN test
lnStartSecs = SECONDS() DO WHILE !EOF() SKIP && should be slower! ENDDO
lnEndSecs = SECONDS() lnElapsed = lnEndSecs - lnStartSecs ? "!EOF():",lnStartSecs,lnEndSecs,lnElapsed
----- Original Message ----- From: <profox (at) cpvfug DOT org> To: <profox@leafe.com> Sent: Friday, January 31, 2003 6:10 AM Subject: is this a fair test? (SCAN vs DO WHILE)
> I've got a little time on my hands and wanted to illustrate the point that SCANs are faster than DO WHILEs, as I've met some skeptics in the past. So I threw this quick test together. Now I know that when developers test things, they need to take into account caching, etc. but I've done this instead: I've moved the SCAN block first, then the DO WHILE and then switched them and ran it again, only to continuously get the same results every time...scan is a mere second if that, whereas DO WHILE takes anywhere between 27 and 33 seconds on my P4 1.9Ghz 512Mb. > > So the question for you Foxperts out there is: what would be required to make this quick study more legitimate if it can be at all? TIA, --Michael > > > #define MAXRECS 100000 > CLEAR > CLEAR ALL > CLOSE ALL > LOCAL lnLoop as Integer, lnStartTime as Datetime, lnEndTime as Datetime, lnElapsed as Number > > CREATE CURSOR test (name c(10), addr1 c(30), addr2 c(30), city c(20), state c(2), postal c(10)) > > FOR lnLoop = 1 TO MAXRECS > INSERT INTO test VALUES ("Ana Alicia","123 Main St.","","Hamburg","PA","12345-6789") > INSERT INTO test VALUES ("Billy Bob","77 Holloway Drive","","West Hollywood","CA","90210-1234") > INSERT INTO test VALUES ("Charlie Chaplin","8619 St. Charles Lane","","Mechanicsburg","PA","17712") > INSERT INTO test VALUES ("Dee Deserata","777 East Park Blvd","PO Box 777","Harrisburg","PA","17111") > INSERT INTO test VALUES ("Mary Poppins","Cantebury","17 Cherry Tree Lane","London","EN","1A1 B5D") > ENDFOR > > GO TOP IN test > SELECT test > lnStartTime = DATETIME() > SCAN > && scan should be faster than DO WHILE !EOF() > ENDSCAN > lnEndTime = DATETIME() > lnElapsed = lnEndTime-lnStartTime > ? "SCAN:",lnStartTime,lnEndTime,lnElapsed > > GO TOP IN test > lnStartTime = DATETIME() > DO WHILE !EOF() > SKIP > && should be slower! > ENDDO > lnEndTime = DATETIME() > lnElapsed = lnEndTime-lnStartTime > ? "!EOF():",lnStartTime,lnEndTime,lnElapsed > > > --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 DOT org > "Code smarter, not harder." > > [excessive quoting removed by server]
©2003 Cotton Mr Jerry P |
|