Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Which Should I Use IF/ENDIF or IIF
Message
 
To
14/06/2002 13:26:29
Guy Pardoe
Pardoe Development Corporation
Peterborough, New Hampshire, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00668532
Message ID:
00668711
Views:
16
>Kirk,
>
>I see that others have posted and said that IIF is faster than IF...ENDIF.
>
>I disagree!
>
>I remember testing this in the past and I've always found IF...ENDIF to be faster. I just ran another test using your example and as I expected, I found IF...ENDIF to be faster.
>
>Here's what I did:
>
>#DEFINE MAXLOOPS 1000000
>ldStartOn = DATE()
>lnStart = SECONDS()
>FOR x = 1 TO MAXLOOPS
>	ldStartOn = ldStartOn + IIF(VARTYPE(ldStartOn)=[D],1,86400)
>ENDFOR
>lnEnd = SECONDS()
>MESSAGEBOX('IIF: ' + TRANSFORM(lnEnd-lnStart))
>
>
>lnStart = SECONDS()
>FOR x = 1 TO MAXLOOPS
>	IF VARTYPE(ldStartOn)=[D]
>		ldStartOn=ldStartOn+1
>	ELSE
>		ldStartOn=ldStartOn+86400
>	ENDIF
>ENDFOR
>lnEnd = SECONDS()
>MESSAGEBOX('IF-ENDIF: ' + TRANSFORM(lnEnd-lnStart))
>
>
Guy,

Hmmm...I could've sworn that at one time I read that IIF() was faster. Maybe it was "conventional wisdom" that no longer applies.

I do, however, have a couple of questions.

First, what were the actual results?

Second, how many times did you run the test and were the results consistent?

Third, did you have anything else other than VFP running at the time?
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform