Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IF...ENDIF, IIF
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
01413551
Message ID:
01413740
Vues:
59
>Naomi:
> I was originally told of the difference in speed 10 years ago. Per your request, I just now tested them, and confirmed the difference. I ran this code:
>**********************************************
>@ 8, 10 say TIME()
>FOR x = 1 TO 100000000
> a = IIF(x%2=0, "Even", "Odd")
>ENDFOR
>@ 10, 10 say TIME()
>
>@ 15, 10 say TIME()
>FOR x = 1 TO 100000000
> IF x%2=0
> a = "Even"
> ELSE
> a = "Odd"
> ENDIF
>ENDFOR
>@ 17, 10 say TIME()
>**********************************************
>IIF took 1:12, and IF...ELSE...ENDIF took 1:23.
>Then, I ran the IF...ELSE...ENDIF first, and IIF second. IF...ELSE...ENDIF took 1:26 and IIF took 1:13.
>
>So, IIF appears to be about 13-15% faster than IF...ELSE...ENDIF.
>
>Jerry

Jerry,

Thanks a lot - I will now note this difference and will prefer IIF in big loops.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform