Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Coding Standards
Message
 
À
10/07/1998 10:18:21
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00115272
Message ID:
00116202
Vues:
25
>So maybe it could be stated that DO WHILE is preferred when the repetitive actions are of indeterminate duration or until a logical flag is set while FOR..ENDFOR is for situations where the number of actions is determined or can logically be determined as a number by program heuristics.

Okay, guys, I've done a little testing. Here's what I get, each test doing one simple calculation (ntest = nloopvar * 5), 1,000,000 loops:

1) FOR with no condition, 4.01 seconds
2) WHILE, 8.60 seconds
3) FOR with EXIT condition if nloopvar = 1,000,000 (so it will check in all iterations), 6.15 seconds

Ran each several times, results are average.

So we note that the FOR is faster even with a terminus condition, at least in a simple test...
The Anonymous Bureaucrat,
and frankly, quite content not to be
a member of either major US political party.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform