Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Shutting Down the Computer
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00532885
Message ID:
00533554
Vues:
10
>Is using #DEFINE with a function slower than otherwise?
>Yes.

Well,
#define cr chr(13)

lnS = seconds()
for lnI = 1 to 10000000
=cr
endfor
?seconds() - lnS

lnS = seconds()
lcCR = cr
for lnI = 1 to 10000000
=lcCR
endfor
?seconds() - lnS
I get 5.5 seconds with the Define and 6 seconds with the variable. I think you're right that setting the variable avoids function call overhead, but that doesn't mean its faster because there's over head reading the variable too. Watch how much this changes when I do this:
#define cr chr(lnX)

lnS = seconds()
lnX =13
for lnI = 1 to 10000000
=cr
endfor
?seconds() - lnS
Now a Constant and a variable is involved, and it drops from 5.5 to almost 8 seconds to run. Knowing that, I don't know if I'd say using a varaible over a function call over is faster.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform