Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Constants and SYS(5) + SYS(2003)
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00267724
Message ID:
00268726
Vues:
38
>>(No cheating by looking at what I say afterwards< g >).
>
>Didn't cheat, and guessed correctly < g >
>
>The first and last tests were idenctical (for all practical purposes). Reason being at run-time they are identical, the VFP compiler has replaced all instance of SHORT_STRING with "AAAAA", so no performance gain or loss by using a constant.
>
>>However, if you replace the defined constant with REPLICATE("A", 5), the first instance will drop to the slowest because it's being re-evaluated on each pass.
>
>Right, the compiler has replaced all instances of SHORT_STRING with REPLICATE("A", 5). Resulting in a decrease in performance by using a constant.
>
>In order to gain performance the compiler would have to evaluate REPLICATE("A", 5) prior to compling, which it doesn't do.
>
>Just for S&G, here is your test using only constants. What suprised me is this gives different results for test 2 and 3 than just the straight code.
>
>
#DEFINE SHORT_STRING       "AAAAA"
>#DEFINE FOR_BEGIN 	        FOR lni = 1 TO 100000
>#DEFINE FOR_END 		NEXT
>#DEFINE STOP_CLOCK 		lnstop = SECONDS()
>#DEFINE DISP_CLOCK 		? lnstop - lnstart
>#DEFINE SHORT_VAR 		lcshort = "AAAAA"
>#DEFINE START_CLOCK 	        lnstart = SECONDS()
>#DEFINE TEST_1 			lcfoo = SHORT_STRING
>#DEFINE TEST_2 			lcfoo = lcshort
>#DEFINE TEST_3 			lcfoo = "AAAAA"
>
>SHORT_VAR
>START_CLOCK
>FOR_BEGIN
>	TEST_1
>FOR_END
>STOP_CLOCK
>DISP_CLOCK
>FOR_BEGIN
>	TEST_2
>FOR_END
>STOP_CLOCK
>DISP_CLOCK
>FOR_BEGIN
>	TEST_3
>FOR_END
>STOP_CLOCK
>DISP_CLOCK
>
Ya know, Roi, for some reason I don't think that this is what the Fox team had in mind < rbg >.
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