Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code Efficiency Question
Message
From
14/03/2001 20:10:56
Cindy Winegarden
Duke University Medical Center
Durham, North Carolina, United States
 
 
To
14/03/2001 19:40:31
Spencer Redfield
Managed Healthcare Northwest, Inc.
Portland, Oregon, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00485113
Message ID:
00485127
Views:
15
Spencer,

Make some type of minimal form with a minimal field to refresh. Then do this:
lnStartIF = SECONDS()
FOR i = 1 TO 1000
    IF SomeCondition
        SomeObject.Refresh()
    ENDIF
ENDFOR
lnEndIF = SECONDS()

lnStartIIF = SECONDS()
FOR i = 1 TO 1000
    IIF(SomeCondition, SomeObject.Refresh(), .F.)
ENDFOR
lnEndIIF

MESSAGEBOX(;
    [The IF statement took ] + ALLT(STR(lnEndIF - lnStartIF)) + ;
    CHR(13) + ;
    [The IIF statement took ] + ALLT(STR(lnEndIIF - lnStartIIF)))
If 1000 times isn't enought to tell the difference, increase it.

Sorry that I hit tab instead of spaces and posted too soon. ;-)



>Anyone have a considered response to the following?
>
>Given that in FoxPro an immediate IF, IIF(), is more efficient than an equivalent IF...ELSE, I had a question.
>
>Would this strategy, in fact, actually be more efficient in conditionally calling a form method. For example, would
>
> =iif( SomeCondition, SomeObject.Refresh(), .F. )
>
>have some efficiency advantage (however trivial) over
>
> if ( SomeCondition )
> SomeObject.Refresh
> endif
>
>I fully appreciate that likely of greater concern are issues of code readability, maintainability, etc. than negligible speed improvements.
>My question is really just for a point of knowledge. Thanks.
Previous
Reply
Map
View

Click here to load this message in the networking platform