Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Eof() or found()
Message
De
18/12/2004 02:31:34
 
 
À
18/12/2004 01:22:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Pro
Database:
Visual FoxPro
Divers
Thread ID:
00970039
Message ID:
00970288
Vues:
15
><snip>
>>If you do not have to use CONTINUE, then:
>>SCAN it is faster, and for a single field LOOKUP() it is 100% faster
>>YOU CAN CHANGE
>>
>>LOCATE XXXX
>>IF FOUND()
>>   YYYY
>>ENDIF
>>
>>WITH
>>
>>SCAN XXXX
>>   YYYYY
>>   EXIT
>>ENDSCAN
>>* ATTENTION, ENDSCAN restore the SCAN workarea
>>
>>OR
>>
>>SCAN XXXX
>>  EXIT
>>ENSCAN
>>IF !EOF()
>> YYYY
>>ENDIF
>>
>>or for a single field
>>
>>IF LOOKUP() AND !EOF()
>>  YYYY
>>ENDIF
>>
>
>Hi Fabio. Any idea why there would be this difference in speed between these methods?
>
>Ciao!

Of course, only hypothesis:
- LOCATE it demands of the additional operations
because VFP have to store the expression and status
for execute a eventual successive CONTINUE operation;
- SCAN it does not have to make this job additional;
honestly this explanation me seems insufficient to explain all,
SCAN has an overload which had to the control of endscan.

- LOOKUP it is the true force of VFP, the inner code of search,
it is effectively 2x faster than LOCATE;
an explanation part is in the fact that LOCATE/SCAN must revalue
all the expression for every record, LOOKUP use a C data driver code (?)
( get the parm2 and compare with the field=parm3 )

An other small improvement can be obtained adding NOOPTIMIZE
(if it is sure that VFP cannot optimize the FOR),
in this case VFP jumps all the phase of analysis for the optimization.
If it is present WHILE, NOOPTIMIZE it is not required,
because with WHILE VFP it cannot optimize the FOR.

Ciao

Fabio
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform