Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
IF...ENDIF, IIF
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01413551
Message ID:
01413740
Views:
60
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform