RE: iif: am I understanding correctly?
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? > > > > > > > > #iif(isDefined("blah"),DE("."),DE(","))# > > > > > > > > > > > > > > . > > > > , > > > > > > > > > > The time to do with IIF is #midtime-starttime# > > Time to do with cfif #endTime-midTime# > > > > 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
RE: iif: am I understanding correctly?
I've seen debates around this so many times I decided to blog it: http://blogs.sanmathi.org/ashwin/2006/07/24/whento-evaluate-and-iif/ In summary - evaluate() and iif() will perform well when the expressions being evaluated remain static, since the Java classes that are compiled to process the expressions are cached in memory. If the expressions change from call to call (different sets of operators and variables), then these will be expensive, since the expressions will have to be compiled into Java classes for every call. -Original Message- From: Snake [mailto:[EMAIL PROTECTED] Sent: Monday, July 24, 2006 2:18 PM To: CF-Talk Subject: RE: iif: am I understanding correctly? This always makes me laugh. Why don't you make a page with CFIF, then run it Now use IIF() and run it What difference do you see in execution time? Bugger all. If you make a big loop that calls IIF 1000 times then you may notice a difference. Also imagine this code Now do the same thing with CFIF/CFELSE, how messy is that. Don't NOT use something just because some cycle counting freak tells you not to because you must save every possible 1000th of a millisecond. At least try it for yourself first. - Snake -Original Message- From: Mike Soultanian [mailto:[EMAIL PROTECTED] Sent: 24 July 2006 04:17 To: CF-Talk Subject: Re: iif: am I understanding correctly? Don't use iif() Always use cfif/cfelse instead of iif(). It is significantly faster and more readable. Mike ~| 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/cf_lists/message.cfm/forumid:4/messageid:247476 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: iif: am I understanding correctly?
This always makes me laugh. Why don't you make a page with CFIF, then run it Now use IIF() and run it What difference do you see in execution time? Bugger all. If you make a big loop that calls IIF 1000 times then you may notice a difference. Also imagine this code Now do the same thing with CFIF/CFELSE, how messy is that. Don't NOT use something just because some cycle counting freak tells you not to because you must save every possible 1000th of a millisecond. At least try it for yourself first. - Snake -Original Message- From: Mike Soultanian [mailto:[EMAIL PROTECTED] Sent: 24 July 2006 04:17 To: CF-Talk Subject: Re: iif: am I understanding correctly? Don't use iif() Always use cfif/cfelse instead of iif(). It is significantly faster and more readable. Mike ~| 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/cf_lists/message.cfm/forumid:4/messageid:247467 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
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.html 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? > > > > #iif(isDefined("blah"),DE("."),DE(","))# > > > > > > > . > > , > > > > > The time to do with IIF is #midtime-starttime# > Time to do with cfif #endTime-midTime# > > 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/cf_lists/message.cfm/forumid:4/messageid:247446 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: iif: am I understanding correctly?
Looks like that works... and for large values of X, looks like this method is the fastest, followed by iif with DE, followed by cfif. Does this mean that it's no longer true that iif is not efficient? If I'm using it only a few times on a page, and it's a little slower then cfif, I don't really care, and if it's faster then cfif when I use it inside something that does a lot of computation, I might as well... More likely I will be using whichever statement make sense, iif inside checkboxes and select's and such and cfif elsewhere, since they are about the same. Russ > -Original Message- > From: Phillip Holmes [mailto:[EMAIL PROTECTED] > Sent: Sunday, July 23, 2006 2:26 AM > To: CF-Talk > Subject: RE: iif: am I understanding correctly? > > You must have copied the code straight off the page. The ticks that my > blog > displays are blowing up CF. > Try this. > > > variables.foo = 1; > out = IIf(variables.foo NEQ 1,"'aString1'","'aString2'"); > writeOutput(out); > > > > Warmest Regards, > > Phillip B. Holmes > http://phillipholmes.com > 214-995-6175 (cell) > > > > > > > -Original Message- > From: Russ [mailto:[EMAIL PROTECTED] > Sent: Sunday, July 23, 2006 1:11 AM > To: CF-Talk > Subject: RE: iif: am I understanding correctly? > > I'm not too sure what you're trying to do in that article, but I couldn't > get it to compile... can you explain what you're doing? > > Russ > > > -Original Message- > > From: Phillip Holmes [mailto:[EMAIL PROTECTED] > > Sent: Sunday, July 23, 2006 1:59 AM > > To: CF-Talk > > Subject: RE: iif: am I understanding correctly? > > > > Brad, > > > > IIF() actually compiles down to a 'short-circuited' if in java. > > > > Here is an article about how to use IIF() without having to use > > evaluate() > > - > > "IIf() without Delayed Evaluation". > > > > http://www.phillipholmes.com/?p=43 > > > > Warmest Regards, > > > > Phillip B. Holmes > > http://phillipholmes.com > > 214-995-6175 (cell) > > > > > > > > > > > > > > -Original Message- > > From: Brad Wood [mailto:[EMAIL PROTECTED] > > Sent: Sunday, July 23, 2006 12:40 AM > > To: CF-Talk > > Subject: RE: iif: am I understanding correctly? > > > > Hmm, I had always just figured that cfif and iif just compiled down to > > the exact same java anyway... > > > > I wonder if one could have an advantage over the other if the > > condition was either true or false all this worrying over a few > > microseconds > > :) > > > > ~Brad > > > > -- > > No virus found in this outgoing message. > > Checked by AVG Free Edition. > > Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date: > > 7/17/2006 > > > > > > > > > > > > ~| 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/cf_lists/message.cfm/forumid:4/messageid:247433 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: iif: am I understanding correctly?
I like iif() because you don't have to assign a temp variable to hold the result of the condition, or have somewhat-duplicated code within a cfif/cfelse block. M!ke -Original Message- From: Brad Wood [mailto:[EMAIL PROTECTED] Sent: Sunday, July 23, 2006 12:40 AM To: CF-Talk Subject: RE: iif: am I understanding correctly? Hmm, I had always just figured that cfif and iif just compiled down to the exact same java anyway... I wonder if one could have an advantage over the other if the condition was either true or false all this worrying over a few microseconds :) ~Brad ~| 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/cf_lists/message.cfm/forumid:4/messageid:247426 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: iif: am I understanding correctly?
You must have copied the code straight off the page. The ticks that my blog displays are blowing up CF. Try this. variables.foo = 1; out = IIf(variables.foo NEQ 1,"'aString1'","'aString2'"); writeOutput(out); Warmest Regards, Phillip B. Holmes http://phillipholmes.com 214-995-6175 (cell) -Original Message- From: Russ [mailto:[EMAIL PROTECTED] Sent: Sunday, July 23, 2006 1:11 AM To: CF-Talk Subject: RE: iif: am I understanding correctly? I'm not too sure what you're trying to do in that article, but I couldn't get it to compile... can you explain what you're doing? Russ > -Original Message- > From: Phillip Holmes [mailto:[EMAIL PROTECTED] > Sent: Sunday, July 23, 2006 1:59 AM > To: CF-Talk > Subject: RE: iif: am I understanding correctly? > > Brad, > > IIF() actually compiles down to a 'short-circuited' if in java. > > Here is an article about how to use IIF() without having to use > evaluate() > - > "IIf() without Delayed Evaluation". > > http://www.phillipholmes.com/?p=43 > > Warmest Regards, > > Phillip B. Holmes > http://phillipholmes.com > 214-995-6175 (cell) > > > > > > > -Original Message- > From: Brad Wood [mailto:[EMAIL PROTECTED] > Sent: Sunday, July 23, 2006 12:40 AM > To: CF-Talk > Subject: RE: iif: am I understanding correctly? > > Hmm, I had always just figured that cfif and iif just compiled down to > the exact same java anyway... > > I wonder if one could have an advantage over the other if the > condition was either true or false all this worrying over a few > microseconds > :) > > ~Brad > > -- > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date: > 7/17/2006 > > > > ~| 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/cf_lists/message.cfm/forumid:4/messageid:247422 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: iif: am I understanding correctly?
I'm not too sure what you're trying to do in that article, but I couldn't get it to compile... can you explain what you're doing? Russ > -Original Message- > From: Phillip Holmes [mailto:[EMAIL PROTECTED] > Sent: Sunday, July 23, 2006 1:59 AM > To: CF-Talk > Subject: RE: iif: am I understanding correctly? > > Brad, > > IIF() actually compiles down to a 'short-circuited' if in java. > > Here is an article about how to use IIF() without having to use evaluate() > - > "IIf() without Delayed Evaluation". > > http://www.phillipholmes.com/?p=43 > > Warmest Regards, > > Phillip B. Holmes > http://phillipholmes.com > 214-995-6175 (cell) > > > > > > > -Original Message----- > From: Brad Wood [mailto:[EMAIL PROTECTED] > Sent: Sunday, July 23, 2006 12:40 AM > To: CF-Talk > Subject: RE: iif: am I understanding correctly? > > Hmm, I had always just figured that cfif and iif just compiled down to the > exact same java anyway... > > I wonder if one could have an advantage over the other if the condition > was > either true or false all this worrying over a few microseconds > :) > > ~Brad > > -- > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date: 7/17/2006 > > > > ~| 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/cf_lists/message.cfm/forumid:4/messageid:247421 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: iif: am I understanding correctly?
Brad, IIF() actually compiles down to a 'short-circuited' if in java. Here is an article about how to use IIF() without having to use evaluate() - "IIf() without Delayed Evaluation". http://www.phillipholmes.com/?p=43 Warmest Regards, Phillip B. Holmes http://phillipholmes.com 214-995-6175 (cell) -Original Message- From: Brad Wood [mailto:[EMAIL PROTECTED] Sent: Sunday, July 23, 2006 12:40 AM To: CF-Talk Subject: RE: iif: am I understanding correctly? Hmm, I had always just figured that cfif and iif just compiled down to the exact same java anyway... I wonder if one could have an advantage over the other if the condition was either true or false all this worrying over a few microseconds :) ~Brad -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.10.1/390 - Release Date: 7/17/2006 ~| 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/cf_lists/message.cfm/forumid:4/messageid:247420 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: iif: am I understanding correctly?
Hmm, I had always just figured that cfif and iif just compiled down to the exact same java anyway... I wonder if one could have an advantage over the other if the condition was either true or false all this worrying over a few microseconds :) ~Brad -Original Message- From: Russ [mailto:[EMAIL PROTECTED] Sent: Sunday, July 23, 2006 12:30 AM To: CF-Talk Subject: RE: iif: am I understanding correctly? 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? #iif(isDefined("blah"),DE("."),DE(","))# . , The time to do with IIF is #midtime-starttime# Time to do with cfif #endTime-midTime# 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/cf_lists/message.cfm/forumid:4/messageid:247418 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: iif: am I understanding correctly?
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? #iif(isDefined("blah"),DE("."),DE(","))# . , The time to do with IIF is #midtime-starttime# Time to do with cfif #endTime-midTime# 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/cf_lists/message.cfm/forumid:4/messageid:247417 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
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/cf_lists/message.cfm/forumid:4/messageid:247393 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: iif: am I understanding correctly?
Josh, I am right with you on that point! I am a huge fan of learning by doing! Keep it up. ... Ben Nadel www.bennadel.com -Original Message- From: Josh Nathanson [mailto:[EMAIL PROTECTED] Sent: Friday, July 21, 2006 6:10 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. Ben -- I guess I like messing around with stuff like this (iif, evaluate etc.) because I feel like I don't fully understand it, and if I can get it to work as desired, maybe I can come to a better understanding of how certain things in CF work in a more general sense. -- Josh - Original Message - From: "Munson, Jacob" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Friday, July 21, 2006 2:52 PM Subject: RE: iif: am I understanding correctly? >> OK, I ran cftimer on both examples, iif and the if/else way, >> and both came >> back 0 ms. So I think in this case, since it's only looping >> over 10 list >> items or whatever, I'll stick with the leaner code. Maybe if >> you were >> looping over thousands of list elements or query rows or >> something, there'd >> be a more noticeable performance hit. > > Interesting. However, if your app ever need's to scale, it /could/ end > up being thousands of list elements, if hundreds of people are firing > that code simultaneously. That's why I usually try to simulate some > traffic by putting the pieces of code I want to test in a loop that runs > thousands of times. It's not the best way to test (a load tester would > be better), but it gives you a better idea. Of course, none of this is > relevant if you know your app will never have that much traffic. :) > > > - > > 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/cf_lists/message.cfm/forumid:4/messageid:247392 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
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. Ben -- I guess I like messing around with stuff like this (iif, evaluate etc.) because I feel like I don't fully understand it, and if I can get it to work as desired, maybe I can come to a better understanding of how certain things in CF work in a more general sense. -- Josh - Original Message - From: "Munson, Jacob" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Friday, July 21, 2006 2:52 PM Subject: RE: iif: am I understanding correctly? >> OK, I ran cftimer on both examples, iif and the if/else way, >> and both came >> back 0 ms. So I think in this case, since it's only looping >> over 10 list >> items or whatever, I'll stick with the leaner code. Maybe if >> you were >> looping over thousands of list elements or query rows or >> something, there'd >> be a more noticeable performance hit. > > Interesting. However, if your app ever need's to scale, it /could/ end > up being thousands of list elements, if hundreds of people are firing > that code simultaneously. That's why I usually try to simulate some > traffic by putting the pieces of code I want to test in a loop that runs > thousands of times. It's not the best way to test (a load tester would > be better), but it gives you a better idea. Of course, none of this is > relevant if you know your app will never have that much traffic. :) > > > - > > 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/cf_lists/message.cfm/forumid:4/messageid:247390 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: iif: am I understanding correctly?
> OK, I ran cftimer on both examples, iif and the if/else way, > and both came > back 0 ms. So I think in this case, since it's only looping > over 10 list > items or whatever, I'll stick with the leaner code. Maybe if > you were > looping over thousands of list elements or query rows or > something, there'd > be a more noticeable performance hit. Interesting. However, if your app ever need's to scale, it /could/ end up being thousands of list elements, if hundreds of people are firing that code simultaneously. That's why I usually try to simulate some traffic by putting the pieces of code I want to test in a loop that runs thousands of times. It's not the best way to test (a load tester would be better), but it gives you a better idea. Of course, none of this is relevant if you know your app will never have that much traffic. :) - 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/cf_lists/message.cfm/forumid:4/messageid:247387 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: iif: am I understanding correctly?
My experience with IIF() is not great, by do the 2/3 arguments have to be string expressions I think... From the docs: If result is True, returns the value of Evaluate(string_expression1); otherwise, returns the value of Evaluate(string_expression2). This, to me, is more of a deterent than the timing. I would rather just pass real values around... But I if the scenario was complicated, you wouldn't be using short hand IF statements. Just my 2 cents. ... Ben Nadel www.bennadel.com -Original Message- From: Josh Nathanson [mailto:[EMAIL PROTECTED] Sent: Friday, July 21, 2006 5:30 PM To: CF-Talk Subject: Re: iif: am I understanding correctly? OK, I ran cftimer on both examples, iif and the if/else way, and both came back 0 ms. So I think in this case, since it's only looping over 10 list items or whatever, I'll stick with the leaner code. Maybe if you were looping over thousands of list elements or query rows or something, there'd be a more noticeable performance hit. -- Josh - Original Message - From: "Munson, Jacob" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Friday, July 21, 2006 2:05 PM Subject: RE: iif: am I understanding correctly? > Yeah, it should. But the question is, is that faster or not? Without > running some tests with cftimer, I'm not sure. But I'm always a fan of > using less code, as long as it doesn't kill the server. :) > >> -Original Message- >> From: loathe [mailto:[EMAIL PROTECTED] >> Sent: Friday, July 21, 2006 3:00 PM >> >> >> >> >> >> >> >> Does the same thing right? >> >> > -----Original Message----- >> > From: Munson, Jacob [mailto:[EMAIL PROTECTED] >> > Sent: Friday, July 21, 2006 4:43 PM >> > To: CF-Talk >> > Subject: RE: iif: am I understanding correctly? >> > >> > Does it? I'm assuming you're referring to dynamic variables (from >> > reading your other reply), but my cfif example has a >> dynamic variable as >> > well. >> > >> > > -Original Message- >> > > From: loathe [mailto:[EMAIL PROTECTED] >> > > Sent: Friday, July 21, 2006 2:37 PM >> > > >> > > But it executes much faster. > > 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/cf_lists/message.cfm/forumid:4/messageid:247386 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: iif: am I understanding correctly?
OK, I ran cftimer on both examples, iif and the if/else way, and both came back 0 ms. So I think in this case, since it's only looping over 10 list items or whatever, I'll stick with the leaner code. Maybe if you were looping over thousands of list elements or query rows or something, there'd be a more noticeable performance hit. -- Josh - Original Message - From: "Munson, Jacob" <[EMAIL PROTECTED]> To: "CF-Talk" Sent: Friday, July 21, 2006 2:05 PM Subject: RE: iif: am I understanding correctly? > Yeah, it should. But the question is, is that faster or not? Without > running some tests with cftimer, I'm not sure. But I'm always a fan of > using less code, as long as it doesn't kill the server. :) > >> -Original Message- >> From: loathe [mailto:[EMAIL PROTECTED] >> Sent: Friday, July 21, 2006 3:00 PM >> >> >> >> >> >> >> >> Does the same thing right? >> >> > -Original Message- >> > From: Munson, Jacob [mailto:[EMAIL PROTECTED] >> > Sent: Friday, July 21, 2006 4:43 PM >> > To: CF-Talk >> > Subject: RE: iif: am I understanding correctly? >> > >> > Does it? I'm assuming you're referring to dynamic variables (from >> > reading your other reply), but my cfif example has a >> dynamic variable as >> > well. >> > >> > > -Original Message- >> > > From: loathe [mailto:[EMAIL PROTECTED] >> > > Sent: Friday, July 21, 2006 2:37 PM >> > > >> > > But it executes much faster. > > 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/cf_lists/message.cfm/forumid:4/messageid:247380 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: iif: am I understanding correctly?
Yeah, it should. But the question is, is that faster or not? Without running some tests with cftimer, I'm not sure. But I'm always a fan of using less code, as long as it doesn't kill the server. :) > -Original Message- > From: loathe [mailto:[EMAIL PROTECTED] > Sent: Friday, July 21, 2006 3:00 PM > > > > > > > > Does the same thing right? > > > -Original Message- > > From: Munson, Jacob [mailto:[EMAIL PROTECTED] > > Sent: Friday, July 21, 2006 4:43 PM > > To: CF-Talk > > Subject: RE: iif: am I understanding correctly? > > > > Does it? I'm assuming you're referring to dynamic variables (from > > reading your other reply), but my cfif example has a > dynamic variable as > > well. > > > > > -Original Message- > > > From: loathe [mailto:[EMAIL PROTECTED] > > > Sent: Friday, July 21, 2006 2:37 PM > > > > > > But it executes much faster. 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/cf_lists/message.cfm/forumid:4/messageid:247369 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: iif: am I understanding correctly?
Does the same thing right? > -Original Message- > From: Munson, Jacob [mailto:[EMAIL PROTECTED] > Sent: Friday, July 21, 2006 4:43 PM > To: CF-Talk > Subject: RE: iif: am I understanding correctly? > > Does it? I'm assuming you're referring to dynamic variables (from > reading your other reply), but my cfif example has a dynamic variable as > well. > > > -Original Message- > > From: loathe [mailto:[EMAIL PROTECTED] > > Sent: Friday, July 21, 2006 2:37 PM > > > > But it executes much faster. > > > > > -Original Message- > > > From: Munson, Jacob [mailto:[EMAIL PROTECTED] > > > Sent: Friday, July 21, 2006 4:22 PM > > > > > > Here's how I understand iif: If the condition is true, > > return the 2nd > > > parameter, otherwise return the 3rd. > > > > > > So in your example, if (didquery and didfind) returns true, the code > > > will evaluate getCust.#i#. Otherwise it will evaluate DE(""). > > > > > > iif is basically just a shorter cfif statement, using your > > example iif, > > > this would do the same thing: > > > > > > But that takes a lot more code. > > 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/cf_lists/message.cfm/forumid:4/messageid:247365 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: iif: am I understanding correctly?
Does it? I'm assuming you're referring to dynamic variables (from reading your other reply), but my cfif example has a dynamic variable as well. > -Original Message- > From: loathe [mailto:[EMAIL PROTECTED] > Sent: Friday, July 21, 2006 2:37 PM > > But it executes much faster. > > > -Original Message- > > From: Munson, Jacob [mailto:[EMAIL PROTECTED] > > Sent: Friday, July 21, 2006 4:22 PM > > > > Here's how I understand iif: If the condition is true, > return the 2nd > > parameter, otherwise return the 3rd. > > > > So in your example, if (didquery and didfind) returns true, the code > > will evaluate getCust.#i#. Otherwise it will evaluate DE(""). > > > > iif is basically just a shorter cfif statement, using your > example iif, > > this would do the same thing: > > > > > > > > > > > > > > But that takes a lot more code. 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/cf_lists/message.cfm/forumid:4/messageid:247360 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
iif: am I understanding correctly?
I have some code that loops over a list of fields to cfparam some attributes. The idea is, if the query (getCust) returns a record, set the attribute to the query.column value; if no record, set the attribute to null. After some hacking around I got it to work as desired, but I don't quite understand how. What I don't get is how iif works. It seems to do the following: - Doesn't evaluate "getCust.#i#" when the page is compiled - Assuming the iif conditional evaluates true, when the list is looped, first evaluates just the "#i#" in "getCust.#i#" to return the proper field name, then evaluates the variable "getCust.FirstName" (for example) to return the correct value. So there is sort of a double evaluation going on. Am I understanding iif correctly or does someone have a better explanation as to how it works. The docs are kind of hard to fathom. -- Josh ~| 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/cf_lists/message.cfm/forumid:4/messageid:247345 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4