Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The other way around
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00385262
Message ID:
00385288
Vues:
12
>From Steve Black's "Text" session at DevConnections, John's would be more efficient. Some VFP optimization on StrVar = StrVar + ...

Bill,

I'm not so sure about that. See below
clear
lcfoo = 'ABCDEF'
lnstart = SECONDS()
FOR lnj = 1 TO 10000
  lcresult = ""
  FOR lni = 1 TO 6
    lcresult = SUBSTR(lcfoo, lni, 1) + lcresult
  NEXT
NEXT
lnstop = SECONDS()
? lnstop - lnstart  && Faster

lnstart = SECONDS()
FOR lnj = 10000 TO 1 STEP -1
  lcresult = ""
  FOR lni = 6 TO 1 STEP -1
    lcresult = SUBSTR(lcfoo, lni, 1) + lcresult
  NEXT
NEXT
lnstop = SECONDS()
? lnstop - lnstart && Slower
I ran this test enough times to be convinced that the first instance was always going to be faster (by about 2%). NBD. What was interesting was that the second nested iteration structure had to be changed. Originally, the lnj variable was incremented. I got an error message and had to change it to the above.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform