Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Things that make me go Hmmmm...
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Things that make me go Hmmmm...
Divers
Thread ID:
00113468
Message ID:
00113468
Vues:
60
Greetings!

My question is not a *problem* with coding as much as a question about why one way would work faster than another.

I have a routine that scans a rushmore-enabled table while searching other tables for a matching record which would result in returning a particular quantity. While experimenting, I found that two not-so-different methods can result in quite a bit of difference in run time.

Here's the fast method:

lnQty = -1
SCAN WHILE lnQty = -1
lnQty = GetQty2()
ENDSCAN

The GetQty2() routine returns (-1) if no match (no returned quantity) could be found.

Now, here's a slight change that adds several minutes to the program's overall run time:

SCAN
lnQty = GetQty2()
IF lnQty >= 0
EXIT
ENDIF
ENDSCAN

I suppose that the SCAN WHILE version takes more advantage of rushmore than the IF/ENDIF version, but is this what is really happening, or is it something else about how one command can work faster than another?

After running across this, I now wonder how much of my other code may be in need of slight optimization.

For example, elsewhere in this same program, I found a way to replace a LOCATE/CONTINUE loop with an embedded call to a SEEK inside a SCAN. The result is that instead of taking over TWO HOURS to complete, the program now runs in just over THREE MINUTES!

Any input about identifying the differences of speed in relation to syntax would be very appreciated.

Michael Reynolds
Santa Barbara, CA
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform