Well we all know what the industry standard has been, but it seems that in real world tests, iif is faster then cfif in some instances, and arguably more readable (especially if you're using it inside a select or radio/checkbox.
Russ > -----Original Message----- > From: Mike Soultanian [mailto:[EMAIL PROTECTED] > Sent: Sunday, July 23, 2006 11:17 PM > To: CF-Talk > Subject: Re: iif: am I understanding correctly? > > I saw this written in the Coldfusion coding practices from Sean Corfield: > > http://livedocs.macromedia.com/wtg/public/coding_standards/performance.htm > l > > Performance "Don'ts" > > The following are 'negative' recommendations, e.g., "Don't do xyz...". > > Don't use evaluate() > > Avoid evaluate() unless there is no other way to write your code (and > there is almost always another way to write your code). > > Don't use iif() > > Always use cfif/cfelse instead of iif(). It is significantly faster and > more readable. > > Mike > > Russ wrote: > > I wrote some test code, and it seems that cfif and iif perform > similarly, > > and sometimes cfif ends up being slower? Is my test code flawed in some > > way? > > > > <cfset startTime=GetTickCount()> > > <cfloop from=1 to=100000 index=x> > > <cfoutput>#iif(isDefined("blah"),DE("."),DE(","))#</cfoutput> > > </cfloop> > > <cfset midTime=GetTickCount()> > > > > <cfloop from=1 to=100000 index=x> > > <cfoutput> > > <cfif isDefined("blah")> > > . > > <cfelse> > > , > > </cfif> > > </cfoutput> > > </cfloop> > > <cfset endTime=getTickCount()> > > <cfoutput><br>The time to do with IIF is #midtime-starttime#</cfoutput> > > <cfoutput><br>Time to do with cfif #endTime-midTime#</cfoutput> > > > > Russ > > > >> -----Original Message----- > >> From: Munson, Jacob [mailto:[EMAIL PROTECTED] > >> Sent: Friday, July 21, 2006 6:34 PM > >> To: CF-Talk > >> Subject: RE: iif: am I understanding correctly? > >> > >>> This part of the app is not going to take heavy traffic, so > >>> the performance > >>> hit would be negligible. However going forward I will always > >>> take into > >>> consideration the possible performance implications of > >>> iif/evaluate/DE. > >> Yeah, and another thing to keep in mind when memorizing things that > >> perform better performance can change with new versions of CF. Or if > >> you move to a different app server, or different OS. That's why I said > >> I like to test my own code, if I'm worried, because I never believe the > >> 'general rules of thumb'. :) > >> > >> > >> --------------- > >> > >> This transmission may contain information that is privileged, > confidential > >> and/or exempt from disclosure under applicable law. If you are not the > >> intended recipient, you are hereby notified that any disclosure, > copying, > >> distribution, or use of the information contained herein (including any > >> reliance thereon) is STRICTLY PROHIBITED. If you received this > >> transmission in error, please immediately contact the sender and > destroy > >> the material in its entirety, whether in electronic or hard copy > format. > >> Thank you. A1. > >> > >> > >> > >> > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:247503 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4