Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SCAN vs. FOR
Message
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00135531
Message ID:
00135699
Views:
8
>>>I'm a little surprised to find that FOR is faster than SCAN (in applicable situations) in some tests I did in vfp6. The old rule was the other way around, I believe...
>>
>>What exactly were you doing?
>
>For each record, call a method to check a substring against other strings, basically. The FOR was something like 10-15% faster, important to me since I have to do this 1000s of times in some research work...

OK..I found your code in another post. I took your code and split it into 3 different prgs. I moved the start time to just before the loop. I quit VFP between each test. I also tested in VFP 5.0a, SP3 and VPF 6.0, released version and ran against data on both a network drive and a local drive. My times were dramatically different than yours, but generally I got the same results. What surprised me the most was the time difference for the local data between 5.0 and 6.0 (About 2.5 times longer in VFP 6.0). Here's my results (all times in seconds):

VFP 5.0, Network data
---------------------
DO WHILE 75.138
SCAN 75.268
FOR 77.151

VFP 5.0, Local data
-------------------
DO WHILE 27.95
SCAN 28.47
FOR 32.317

VFP 6.0, Network data
---------------------
DO WHILE 85.063
SCAN 95.968
FOR 93.294

VFP 6.0, Local data
-------------------
DO WHILE 78.713
SCAN 73.716
FOR 76.149
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform