RE: Which is quicker
sorry, you're right! ... too quick! -Original Message- From: Philip Arnold [mailto:[EMAIL PROTECTED] Sent: Thursday, February 12, 2004 3:26 PM To: CF-Talk Subject: RE: Which is quicker > or outside the tag: > > cfif x=y > isChecked = "checked" > else > isChecked = "checked" > /cfif > > Only if you want it to always be checked Oh, and to break since you can't do "cfif x=y" it'd have to be "cfif x eq y" [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
doh still in the transitional phase from ASP to ColdFusion but you catch my drift -Original Message- From: Philip Arnold [mailto:[EMAIL PROTECTED] Sent: 12 February 2004 14:26 To: CF-Talk Subject: RE: Which is quicker > or outside the tag: > > cfif x=y > isChecked = "checked" > else > isChecked = "checked" > /cfif > > Only if you want it to always be checked Oh, and to break since you can't do "cfif x=y" it'd have to be "cfif x eq y" _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
> or outside the tag: > > cfif x=y > isChecked = "checked" > else > isChecked = "checked" > /cfif > > Only if you want it to always be checked Oh, and to break since you can't do "cfif x=y" it'd have to be "cfif x eq y" [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
or outside the tag: cfif x=y isChecked = "checked" else isChecked = "checked" /cfif -Original Message- From: Bill Grover [mailto:[EMAIL PROTECTED] Sent: Thursday, February 12, 2004 3:03 PM To: CF-Talk Subject: RE: Which is quicker Interesting, thanks. I thought I had done that before and received an error about not being able to nest the CFIF tag inside another tag. But it is very possible I was using a CFINPUT instead of a regular INPUT. I was probably on v4.01 at the time as well. __ Bill Grover Manager, Information Systems Phone: 301.424.3300 x3324 EU Services, Inc. FAX: 301.424.3696 649 North Horners Lane E-Mail: [EMAIL PROTECTED] Rockville, MD 20850-1299 WWW: http://www.euservices.com __ -Original Message- From: David Ashworth [mailto:[EMAIL PROTECTED] Sent: Thursday, February 12, 2004 9:00 AM To: CF-Talk Subject: RE: Which is quicker you wouldn't have to code it twice using CFIF just have the CFIF around the checked parameter checked> -Original Message- From: Bill Grover [mailto:[EMAIL PROTECTED] Sent: 12 February 2004 12:47 To: CF-Talk Subject: RE: Which is quicker The one place I've found that I really like the IIF is to use it in areas like the following code sample: name="#REQUEST.cReorderFormArtPrefix##ReorderJob.ljob#" value="Yes" #IIF(laReorderJobs[lnLoop][REQUEST.cReorderFormArtPrefix] NEQ "", DE("CHECKED"), DE(""))#> I found using it this way is much more readable in my code then using and having to code the almost identical tag twice with only the "CHECKED" option in or out. __ Bill Grover Manager, Information Systems Phone:301.424.3300 x3324 EU Services, Inc. FAX:301.424.3696 649 North Horners Lane E-Mail:[EMAIL PROTECTED] Rockville, MD 20850-1299 WWW:http://www.euservices.com __ -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 6:27 PM To: CF-Talk Subject: RE: Which is quicker Really? I'm getting about 50 and 150ms respectively. So for me while iif() is slower it's only one hundredth of a millisecond difference i.e. way below anything I'd worry about. So it's a style thing then. -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 11:11 a.m. To: CF-Talk Subject: RE: Which is quicker You may get these results due to use of de(), run this code, which I think is more fair: 12 #temp-getTickCount()# #iif(i mod 2, 1, 2)# #temp-getTickCount()# I got 15 - 16 as results for both of them with some variations both ways which I discard as noise. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:57 PM To: CF-Talk Subject: RE: Which is quicker My test indicates iif() is about 400% slower. But the real issue is code readability. If you think it's more readable in any or all circumstances, I say go for it. Personally, I think this example demonstrates it is less readable. There are probably other example that show it in a better light. Here's my sample: !? #iif(i mod 2, de("!"), de("?"))# -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:47 a.m. To: CF-Talk Subject: RE: Which is quicker I don't know why people don't like iif (immediate if), it is as quick as cfif and takes only one line. For simple things, like "if x < y print true else print false", I think using iif makes code shorter without sacrificing clarity and speed. If you don't believe iif is fast then I encourage you to write a small test and see for yourself. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:34 PM To: CF-Talk Subject: RE: Which is quicker cfswitch is both quicker and more elegant. The only downside is that it doesn't handle dynamic values. Iii() is one of those functions, like evaluate(), usage of which is generally discouraged. -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:30 a.m. To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL P
RE: Which is quicker
> Interesting, thanks. I thought I had done that before and > received an error about not being able to nest the CFIF tag > inside another tag. But it is very possible I was using a > CFINPUT instead of a regular INPUT. I was probably on v4.01 > at the time as well. It's only CF tags that you can't embed other tags inside of, anything else is just output, so you can do whatever you want inside the "tags" [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
> The one place I've found that I really like the IIF is to use > it in areas like the following code sample: > > >name="#REQUEST.cReorderFormArtPrefix##ReorderJob.ljob#" >value="Yes" > > #IIF(laReorderJobs[lnLoop][REQUEST.cReorderFormArtPrefix] NEQ "", > DE("CHECKED"), DE(""))#> > > I found using it this way is much more readable in my code > then using and having to code the almost identical > tag twice with only the "CHECKED" option in or out. I prefer not using DE() as it can be horribly slow #IIF(laReorderJobs[lnLoop][REQUEST.cReorderFormArtPrefix] NEQ "", "'CHECKED'", "''")# Once you are used to it, it's just as readable Although, I don't use IIF() that often as I tend to do things like this in CFSCRIPT and set a variable to put there; checkField=""; if (Len(laReorderJobs[lnLoop][REQUEST.cReorderFormArtPrefix])) { checkField="checked"; } name="#REQUEST.cReorderFormArtPrefix##ReorderJob.ljob#"> [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
Interesting, thanks. I thought I had done that before and received an error about not being able to nest the CFIF tag inside another tag. But it is very possible I was using a CFINPUT instead of a regular INPUT. I was probably on v4.01 at the time as well. __ Bill Grover Manager, Information Systems Phone: 301.424.3300 x3324 EU Services, Inc. FAX: 301.424.3696 649 North Horners Lane E-Mail: [EMAIL PROTECTED] Rockville, MD 20850-1299 WWW: http://www.euservices.com __ -Original Message- From: David Ashworth [mailto:[EMAIL PROTECTED] Sent: Thursday, February 12, 2004 9:00 AM To: CF-Talk Subject: RE: Which is quicker you wouldn't have to code it twice using CFIF just have the CFIF around the checked parameter checked> -Original Message- From: Bill Grover [mailto:[EMAIL PROTECTED] Sent: 12 February 2004 12:47 To: CF-Talk Subject: RE: Which is quicker The one place I've found that I really like the IIF is to use it in areas like the following code sample: name="#REQUEST.cReorderFormArtPrefix##ReorderJob.ljob#" value="Yes" #IIF(laReorderJobs[lnLoop][REQUEST.cReorderFormArtPrefix] NEQ "", DE("CHECKED"), DE(""))#> I found using it this way is much more readable in my code then using and having to code the almost identical tag twice with only the "CHECKED" option in or out. __ Bill Grover Manager, Information Systems Phone:301.424.3300 x3324 EU Services, Inc. FAX:301.424.3696 649 North Horners Lane E-Mail:[EMAIL PROTECTED] Rockville, MD 20850-1299 WWW:http://www.euservices.com __ -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 6:27 PM To: CF-Talk Subject: RE: Which is quicker Really? I'm getting about 50 and 150ms respectively. So for me while iif() is slower it's only one hundredth of a millisecond difference i.e. way below anything I'd worry about. So it's a style thing then. -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 11:11 a.m. To: CF-Talk Subject: RE: Which is quicker You may get these results due to use of de(), run this code, which I think is more fair: 12 #temp-getTickCount()# #iif(i mod 2, 1, 2)# #temp-getTickCount()# I got 15 - 16 as results for both of them with some variations both ways which I discard as noise. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:57 PM To: CF-Talk Subject: RE: Which is quicker My test indicates iif() is about 400% slower. But the real issue is code readability. If you think it's more readable in any or all circumstances, I say go for it. Personally, I think this example demonstrates it is less readable. There are probably other example that show it in a better light. Here's my sample: !? #iif(i mod 2, de("!"), de("?"))# -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:47 a.m. To: CF-Talk Subject: RE: Which is quicker I don't know why people don't like iif (immediate if), it is as quick as cfif and takes only one line. For simple things, like "if x < y print true else print false", I think using iif makes code shorter without sacrificing clarity and speed. If you don't believe iif is fast then I encourage you to write a small test and see for yourself. TK -----Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:34 PM To: CF-Talk Subject: RE: Which is quicker cfswitch is both quicker and more elegant. The only downside is that it doesn't handle dynamic values. Iii() is one of those functions, like evaluate(), usage of which is generally discouraged. -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:30 a.m. To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legisl
RE: Which is quicker
you wouldn't have to code it twice using CFIF just have the CFIF around the checked parameter checked> -Original Message- From: Bill Grover [mailto:[EMAIL PROTECTED] Sent: 12 February 2004 12:47 To: CF-Talk Subject: RE: Which is quicker The one place I've found that I really like the IIF is to use it in areas like the following code sample: name="#REQUEST.cReorderFormArtPrefix##ReorderJob.ljob#" value="Yes" #IIF(laReorderJobs[lnLoop][REQUEST.cReorderFormArtPrefix] NEQ "", DE("CHECKED"), DE(""))#> I found using it this way is much more readable in my code then using and having to code the almost identical tag twice with only the "CHECKED" option in or out. __ Bill Grover Manager, Information Systems Phone:301.424.3300 x3324 EU Services, Inc. FAX:301.424.3696 649 North Horners Lane E-Mail:[EMAIL PROTECTED] Rockville, MD 20850-1299 WWW:http://www.euservices.com __ -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 6:27 PM To: CF-Talk Subject: RE: Which is quicker Really? I'm getting about 50 and 150ms respectively. So for me while iif() is slower it's only one hundredth of a millisecond difference i.e. way below anything I'd worry about. So it's a style thing then. -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 11:11 a.m. To: CF-Talk Subject: RE: Which is quicker You may get these results due to use of de(), run this code, which I think is more fair: 12 #temp-getTickCount()# #iif(i mod 2, 1, 2)# #temp-getTickCount()# I got 15 - 16 as results for both of them with some variations both ways which I discard as noise. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:57 PM To: CF-Talk Subject: RE: Which is quicker My test indicates iif() is about 400% slower. But the real issue is code readability. If you think it's more readable in any or all circumstances, I say go for it. Personally, I think this example demonstrates it is less readable. There are probably other example that show it in a better light. Here's my sample: !? #iif(i mod 2, de("!"), de("?"))# -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:47 a.m. To: CF-Talk Subject: RE: Which is quicker I don't know why people don't like iif (immediate if), it is as quick as cfif and takes only one line. For simple things, like "if x < y print true else print false", I think using iif makes code shorter without sacrificing clarity and speed. If you don't believe iif is fast then I encourage you to write a small test and see for yourself. TK -----Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:34 PM To: CF-Talk Subject: RE: Which is quicker cfswitch is both quicker and more elegant. The only downside is that it doesn't handle dynamic values. Iii() is one of those functions, like evaluate(), usage of which is generally discouraged. -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:30 a.m. To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legislated confidentiality and/or is legally privileged. If you are not the intended recipient you are prohibited from disseminating, distributing or copying this e-mail. Any opinion expressed in this e-mail may not necessarily be that of the WorkCover Corporation of South Australia. Although precautions have been taken, the sender cannot warrant that this e-mail or any files transmitted with it are free of viruses or any other defect. If you have received this e-mail in error, please notify the sender immediately by return e-mail and destroy the original e-mail and any copies. _ _ _ _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
The one place I've found that I really like the IIF is to use it in areas like the following code sample: name="#REQUEST.cReorderFormArtPrefix##ReorderJob.ljob#" value="Yes" #IIF(laReorderJobs[lnLoop][REQUEST.cReorderFormArtPrefix] NEQ "", DE("CHECKED"), DE(""))#> I found using it this way is much more readable in my code then using and having to code the almost identical tag twice with only the "CHECKED" option in or out. __ Bill Grover Manager, Information Systems Phone:301.424.3300 x3324 EU Services, Inc. FAX:301.424.3696 649 North Horners Lane E-Mail:[EMAIL PROTECTED] Rockville, MD 20850-1299 WWW:http://www.euservices.com __ -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 6:27 PM To: CF-Talk Subject: RE: Which is quicker Really? I'm getting about 50 and 150ms respectively. So for me while iif() is slower it's only one hundredth of a millisecond difference i.e. way below anything I'd worry about. So it's a style thing then. -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 11:11 a.m. To: CF-Talk Subject: RE: Which is quicker You may get these results due to use of de(), run this code, which I think is more fair: 12 #temp-getTickCount()# #iif(i mod 2, 1, 2)# #temp-getTickCount()# I got 15 - 16 as results for both of them with some variations both ways which I discard as noise. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:57 PM To: CF-Talk Subject: RE: Which is quicker My test indicates iif() is about 400% slower. But the real issue is code readability. If you think it's more readable in any or all circumstances, I say go for it. Personally, I think this example demonstrates it is less readable. There are probably other example that show it in a better light. Here's my sample: !? #iif(i mod 2, de("!"), de("?"))# -Original Message----- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:47 a.m. To: CF-Talk Subject: RE: Which is quicker I don't know why people don't like iif (immediate if), it is as quick as cfif and takes only one line. For simple things, like "if x < y print true else print false", I think using iif makes code shorter without sacrificing clarity and speed. If you don't believe iif is fast then I encourage you to write a small test and see for yourself. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:34 PM To: CF-Talk Subject: RE: Which is quicker cfswitch is both quicker and more elegant. The only downside is that it doesn't handle dynamic values. Iii() is one of those functions, like evaluate(), usage of which is generally discouraged. -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:30 a.m. To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legislated confidentiality and/or is legally privileged. If you are not the intended recipient you are prohibited from disseminating, distributing or copying this e-mail. Any opinion expressed in this e-mail may not necessarily be that of the WorkCover Corporation of South Australia. Although precautions have been taken, the sender cannot warrant that this e-mail or any files transmitted with it are free of viruses or any other defect. If you have received this e-mail in error, please notify the sender immediately by return e-mail and destroy the original e-mail and any copies. _ _ _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
Thank you Barney for more scientific tests of conditional's performance. I hope these tests will show once and for all that in CFMX iif is nothing to be afraid of as far as speed goes. The results for cfswitch slower performance also surprise me, didn't expect that, good to know. TK -Original Message- From: Barney Boisvert [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 7:43 PM To: CF-Talk Subject: RE: Which is quicker I ran several tests to check the relative performance of the various conditional things. In every case, the idea was to check a variable containing either a string or an int, against one or two other constants of the same type, or select a default (2- or 3- way). The action for the matched conditional was to assign a separate (preinitialized) variable with a constant of the same type. Each conditional was implemented using each of the three conditional constructs CF provides. I have provided results below for two separate runs of 100,000 iterations each below, for 24 records (two each for the 12 tests). Overall results were that CFIF and IIF were similar in execution profile, with CFIF having a slight edge when dealing with strings (presumably because of the dynamic evaluation), and IIF having a slight edge with more than two conditionals (presumably because it can be nested 'better'). CFSWITCH was noticably slower across the board, particularly when dealing with strings (which surprises me). Test server was running ColdFusion Server Standard 6,1,0,63958 on top of Apache/2.0.47, on a 600mHz AMD k6-2 machine with 256MB of RAM (my pathetic dev server that also has to cope with serving files to the office, run MySQL, and act as our internet gateway/router). If anyone's interested in the test script or the excel spreadsheet of data, I'd be happy to send it to you. Just email me off list. time mechanism data ways 1103 CFIF Integers 2 1208 IIF Integers 2 2042 CFSWITCH Integers 2 2285 CFIF Integers 2 2669 IIF Integers 2 3763 CFSWITCH Integers 2 786 CFIF Strings 2 885 IIF Strings 2 891 CFIF Strings 2 966 IIF Strings 2 5756 CFSWITCH Strings 2 6722 CFSWITCH Strings 2 1173 IIF Integers 3 1452 IIF Integers 3 1611 CFIF Integers 3 2102 CFSWITCH Integers 3 2323 CFSWITCH Integers 3 3908 CFIF Integers 3 888 CFIF Strings 3 1089 IIF Strings 3 1908 CFIF Strings 3 2188 IIF Strings 3 7749 CFSWITCH Strings 3 11211 CFSWITCH Strings 3 Cheers, barneyb > -Original Message- > From: Matthew Walker [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 3:39 PM > To: CF-Talk > Subject: RE: Which is quicker > > Interesting that people's ideas of good programming style are > so different. > I think we generally consider good style to be the way we as > individuals > normally do it, i.e. consistent style is good style. I would > always use > cfswitch where there are more than two static values to choose from, > therefore to me that's good style. I would also write > recordset.recordcount> and consider that elegant. Others find > it appalling. > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
I ran several tests to check the relative performance of the various conditional things. In every case, the idea was to check a variable containing either a string or an int, against one or two other constants of the same type, or select a default (2- or 3- way). The action for the matched conditional was to assign a separate (preinitialized) variable with a constant of the same type. Each conditional was implemented using each of the three conditional constructs CF provides. I have provided results below for two separate runs of 100,000 iterations each below, for 24 records (two each for the 12 tests). Overall results were that CFIF and IIF were similar in execution profile, with CFIF having a slight edge when dealing with strings (presumably because of the dynamic evaluation), and IIF having a slight edge with more than two conditionals (presumably because it can be nested 'better'). CFSWITCH was noticably slower across the board, particularly when dealing with strings (which surprises me). Test server was running ColdFusion Server Standard 6,1,0,63958 on top of Apache/2.0.47, on a 600mHz AMD k6-2 machine with 256MB of RAM (my pathetic dev server that also has to cope with serving files to the office, run MySQL, and act as our internet gateway/router). If anyone's interested in the test script or the excel spreadsheet of data, I'd be happy to send it to you. Just email me off list. time mechanism data ways 1103 CFIF Integers 2 1208 IIF Integers 2 2042 CFSWITCH Integers 2 2285 CFIF Integers 2 2669 IIF Integers 2 3763 CFSWITCH Integers 2 786 CFIF Strings 2 885 IIF Strings 2 891 CFIF Strings 2 966 IIF Strings 2 5756 CFSWITCH Strings 2 6722 CFSWITCH Strings 2 1173 IIF Integers 3 1452 IIF Integers 3 1611 CFIF Integers 3 2102 CFSWITCH Integers 3 2323 CFSWITCH Integers 3 3908 CFIF Integers 3 888 CFIF Strings 3 1089 IIF Strings 3 1908 CFIF Strings 3 2188 IIF Strings 3 7749 CFSWITCH Strings 3 11211 CFSWITCH Strings 3 Cheers, barneyb > -Original Message- > From: Matthew Walker [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 3:39 PM > To: CF-Talk > Subject: RE: Which is quicker > > Interesting that people's ideas of good programming style are > so different. > I think we generally consider good style to be the way we as > individuals > normally do it, i.e. consistent style is good style. I would > always use > cfswitch where there are more than two static values to choose from, > therefore to me that's good style. I would also write > recordset.recordcount> and consider that elegant. Others find > it appalling. > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
Interesting that people's ideas of good programming style are so different. I think we generally consider good style to be the way we as individuals normally do it, i.e. consistent style is good style. I would always use cfswitch where there are more than two static values to choose from, therefore to me that's good style. I would also write recordset.recordcount> and consider that elegant. Others find it appalling. -Original Message- From: Jim McAtee [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 11:34 a.m. To: CF-Talk Subject: Re: Which is quicker - Original Message - From: "Matthew Walker" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Wednesday, February 11, 2004 3:34 PM Subject: RE: Which is quicker > cfswitch is both quicker and more elegant. The only downside is that it > doesn't handle dynamic values. That's funny. I find CFSWITCH to be far from elegant. Mostly due to CF's tag-based nature. You end up with a lot more crap in your code where you're closing each CFCASE block. I think a CFIF statement is usually a lot more readable as well as being more flexible. _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Which is quicker
- Original Message - From: "Matthew Walker" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Wednesday, February 11, 2004 3:34 PM Subject: RE: Which is quicker > cfswitch is both quicker and more elegant. The only downside is that it > doesn't handle dynamic values. That's funny. I find CFSWITCH to be far from elegant. Mostly due to CF's tag-based nature. You end up with a lot more crap in your code where you're closing each CFCASE block. I think a CFIF statement is usually a lot more readable as well as being more flexible. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
Really? I'm getting about 50 and 150ms respectively. So for me while iif() is slower it's only one hundredth of a millisecond difference i.e. way below anything I'd worry about. So it's a style thing then. -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 11:11 a.m. To: CF-Talk Subject: RE: Which is quicker You may get these results due to use of de(), run this code, which I think is more fair: 12 #temp-getTickCount()# #iif(i mod 2, 1, 2)# #temp-getTickCount()# I got 15 - 16 as results for both of them with some variations both ways which I discard as noise. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:57 PM To: CF-Talk Subject: RE: Which is quicker My test indicates iif() is about 400% slower. But the real issue is code readability. If you think it's more readable in any or all circumstances, I say go for it. Personally, I think this example demonstrates it is less readable. There are probably other example that show it in a better light. Here's my sample: !? #iif(i mod 2, de("!"), de("?"))# -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:47 a.m. To: CF-Talk Subject: RE: Which is quicker I don't know why people don't like iif (immediate if), it is as quick as cfif and takes only one line. For simple things, like "if x < y print true else print false", I think using iif makes code shorter without sacrificing clarity and speed. If you don't believe iif is fast then I encourage you to write a small test and see for yourself. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:34 PM To: CF-Talk Subject: RE: Which is quicker cfswitch is both quicker and more elegant. The only downside is that it doesn't handle dynamic values. Iii() is one of those functions, like evaluate(), usage of which is generally discouraged. -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:30 a.m. To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legislated confidentiality and/or is legally privileged. If you are not the intended recipient you are prohibited from disseminating, distributing or copying this e-mail. Any opinion expressed in this e-mail may not necessarily be that of the WorkCover Corporation of South Australia. Although precautions have been taken, the sender cannot warrant that this e-mail or any files transmitted with it are free of viruses or any other defect. If you have received this e-mail in error, please notify the sender immediately by return e-mail and destroy the original e-mail and any copies. _ _ _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
Ooops, I forgot to say that my tests are all on MX6.1, of course on CF5 'iif' is painfully slow. TK -Original Message- From: Philip Arnold [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 6:11 PM To: CF-Talk Subject: RE: Which is quicker > I don't know why people don't like iif (immediate if), it is > as quick as cfif and takes only one line. For simple things, > like "if x < y print true else print false", I think using > iif makes code shorter without sacrificing clarity and speed. > > If you don't believe iif is fast then I encourage you to > write a small test and see for yourself. This depends on the version of CF If you're running pre-MX, then it's 2.5 times slower [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
I think that the point that I am trying to get across is that there are situations where 'iif' is useful. It is not as useful as say 'if', but it was placed inside CFML for a reason. Thus, if you know what you are doing using iif is in my opinion acceptable practice. TK -Original Message- From: Barney Boisvert [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 6:00 PM To: CF-Talk Subject: RE: Which is quicker Not always the case, because of it's dynamic evaluation capabilities. And those same dynamic evaluation capabilities make it a pain to work with in a lot of situations. > -Original Message- > From: Tom Kitta [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 2:47 PM > To: CF-Talk > Subject: RE: Which is quicker > > I don't know why people don't like iif (immediate if), it is > as quick as > cfif and takes only one line. For simple things, like "if x < > y print true > else print false", I think using iif makes code shorter > without sacrificing > clarity and speed. > > If you don't believe iif is fast then I encourage you to > write a small test > and see for yourself. > > TK > -Original Message- > From: Matthew Walker [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 5:34 PM > To: CF-Talk > Subject: RE: Which is quicker > > > cfswitch is both quicker and more elegant. The only > downside is that it > doesn't handle dynamic values. > > Iii() is one of those functions, like evaluate(), usage of which is > generally discouraged. > > -Original Message- > From: Parker, Kevin [mailto:[EMAIL PROTECTED] > Sent: Thursday, 12 February 2004 10:30 a.m. > To: CF-Talk > Subject: Which is quicker > > Can I get a little advice on which is quicker or which is > the preferred > way > of programming - there are 8 items to select from: > > CFIF, CFCASE or IIF > > TIA! > > +++ > Kevin Parker > Web Services Manager > WorkCover Corporation > > p: 08 8233 2548 > e: [EMAIL PROTECTED] > w: www.workcover.com > +++ > > > ** > ** > This e-mail is intended for the use of the addressee only. It may > contain information that is protected by legislated confidentiality > and/or is legally privileged. If you are not the intended > recipient you > are prohibited from disseminating, distributing or copying > this e-mail. > > Any opinion expressed in this e-mail may not necessarily be > that of the > WorkCover Corporation of South Australia. Although precautions have > been taken, the sender cannot warrant that this e-mail or any files > transmitted with it are free of viruses or any other defect. > > If you have received this e-mail in error, please notify the sender > immediately by return e-mail and destroy the original e-mail and any > copies. > > ** > ** > > _ > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
You may get these results due to use of de(), run this code, which I think is more fair: 12 #temp-getTickCount()# #iif(i mod 2, 1, 2)# #temp-getTickCount()# I got 15 - 16 as results for both of them with some variations both ways which I discard as noise. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:57 PM To: CF-Talk Subject: RE: Which is quicker My test indicates iif() is about 400% slower. But the real issue is code readability. If you think it's more readable in any or all circumstances, I say go for it. Personally, I think this example demonstrates it is less readable. There are probably other example that show it in a better light. Here's my sample: !? #iif(i mod 2, de("!"), de("?"))# -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:47 a.m. To: CF-Talk Subject: RE: Which is quicker I don't know why people don't like iif (immediate if), it is as quick as cfif and takes only one line. For simple things, like "if x < y print true else print false", I think using iif makes code shorter without sacrificing clarity and speed. If you don't believe iif is fast then I encourage you to write a small test and see for yourself. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:34 PM To: CF-Talk Subject: RE: Which is quicker cfswitch is both quicker and more elegant. The only downside is that it doesn't handle dynamic values. Iii() is one of those functions, like evaluate(), usage of which is generally discouraged. -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:30 a.m. To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legislated confidentiality and/or is legally privileged. If you are not the intended recipient you are prohibited from disseminating, distributing or copying this e-mail. Any opinion expressed in this e-mail may not necessarily be that of the WorkCover Corporation of South Australia. Although precautions have been taken, the sender cannot warrant that this e-mail or any files transmitted with it are free of viruses or any other defect. If you have received this e-mail in error, please notify the sender immediately by return e-mail and destroy the original e-mail and any copies. _ _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
> I don't know why people don't like iif (immediate if), it is > as quick as cfif and takes only one line. For simple things, > like "if x < y print true else print false", I think using > iif makes code shorter without sacrificing clarity and speed. > > If you don't believe iif is fast then I encourage you to > write a small test and see for yourself. This depends on the version of CF If you're running pre-MX, then it's 2.5 times slower [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Which is quicker
I find it far more readable, especially in a circumstance like: whong frewp ... Quick and easy... although 400% slower :) - Jim Matthew Walker wrote: > My test indicates iif() is about 400% slower. But the real issue is code > readability. If you think it's more readable in any or all > circumstances, I > say go for it. Personally, I think this example demonstrates it is less > readable. There are probably other example that show it in a better light. > > Here's my sample: > > > > > > > > !? > > > > > > > > > > > > > > #iif(i mod 2, de("!"), de("?"))# > > > > > > > > > > -Original Message- > From: Tom Kitta [mailto:[EMAIL PROTECTED] > Sent: Thursday, 12 February 2004 10:47 a.m. > To: CF-Talk > Subject: RE: Which is quicker > > I don't know why people don't like iif (immediate if), it is as quick as > cfif and takes only one line. For simple things, like "if x < y print true > else print false", I think using iif makes code shorter without > sacrificing > clarity and speed. > > If you don't believe iif is fast then I encourage you to write a small > test > and see for yourself. > > TK > -Original Message- > From: Matthew Walker [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 5:34 PM > To: CF-Talk > Subject: RE: Which is quicker > > cfswitch is both quicker and more elegant. The only downside is that it > doesn't handle dynamic values. > > Iii() is one of those functions, like evaluate(), usage of which is > generally discouraged. > > -Original Message- > From: Parker, Kevin [mailto:[EMAIL PROTECTED] > Sent: Thursday, 12 February 2004 10:30 a.m. > To: CF-Talk > Subject: Which is quicker > > Can I get a little advice on which is quicker or which is the preferred > way > of programming - there are 8 items to select from: > > CFIF, CFCASE or IIF > > TIA! > > +++ > Kevin Parker > Web Services Manager > WorkCover Corporation > > p: 08 8233 2548 > e: [EMAIL PROTECTED] > w: www.workcover.com > +++ > > > This e-mail is intended for the use of the addressee only. It may > contain information that is protected by legislated confidentiality > and/or is legally privileged. If you are not the intended recipient you > are prohibited from disseminating, distributing or copying this e-mail. > > Any opinion expressed in this e-mail may not necessarily be that of the > WorkCover Corporation of South Australia. Although precautions have > been taken, the sender cannot warrant that this e-mail or any files > transmitted with it are free of viruses or any other defect. > > If you have received this e-mail in error, please notify the sender > immediately by return e-mail and destroy the original e-mail and any > copies. > > > _ > > _ > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
FYI my test: cfif twice as fast as cfswitch, which is disappointing. red orange yellow green blue indigo violet red orange yellow green blue indigo violet -Original Message- From: Barney Boisvert [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:45 a.m. To: CF-Talk Subject: RE: Which is quicker Actually, they both only check until they find a match, assuming you're using CFELSEIF in there to bind them all togther. Both constructs are done as IF statements at the Java level, so you don't get the 'usual' benefit of a switch construct. CFSWITCH might be faster (particularly if the _expression_ value is expensive to compute) if the CF engine uses a temporary variable, but for simple expressions, that might actually slow things down, because doing that's an extra step to do. Cheers, barneyb > -Original Message- > From: Bryan Stevenson [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 2:33 PM > To: CF-Talk > Subject: Re: Which is quicker > > CFCASE will be a tad quicker > > Basically CFIF has to check ALL conditions where CFCASE will > stop when it finds the correct case. > > Bryan Stevenson B.Comm. > VP & Director of E-Commerce Development > Electric Edge Systems Group Inc. > t. 250.920.8830 > e. [EMAIL PROTECTED] > > - > Macromedia Associate Partner > www.macromedia.com > - > Vancouver Island ColdFusion Users Group > Founder & Director > www.cfug-vancouverisland.com > - Original Message - > From: Parker, Kevin > To: CF-Talk > Sent: Wednesday, February 11, 2004 2:29 PM > Subject: Which is quicker > > > Can I get a little advice on which is quicker or which is > the preferred way > of programming - there are 8 items to select from: > > CFIF, CFCASE or IIF > > TIA! > > +++ > Kevin Parker > Web Services Manager > WorkCover Corporation > > p: 08 8233 2548 > e: [EMAIL PROTECTED] > w: www.workcover.com > +++ > > > ** > ** > This e-mail is intended for the use of the addressee only. It may > contain information that is protected by legislated confidentiality > and/or is legally privileged. If you are not the intended > recipient you > are prohibited from disseminating, distributing or copying > this e-mail. > > Any opinion expressed in this e-mail may not necessarily be > that of the > WorkCover Corporation of South Australia. Although precautions have > been taken, the sender cannot warrant that this e-mail or any files > transmitted with it are free of viruses or any other defect. > > If you have received this e-mail in error, please notify the sender > immediately by return e-mail and destroy the original e-mail and any > copies. > > ** > ** > > _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
Not always the case, because of it's dynamic evaluation capabilities. And those same dynamic evaluation capabilities make it a pain to work with in a lot of situations. > -Original Message- > From: Tom Kitta [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 2:47 PM > To: CF-Talk > Subject: RE: Which is quicker > > I don't know why people don't like iif (immediate if), it is > as quick as > cfif and takes only one line. For simple things, like "if x < > y print true > else print false", I think using iif makes code shorter > without sacrificing > clarity and speed. > > If you don't believe iif is fast then I encourage you to > write a small test > and see for yourself. > > TK > -Original Message- > From: Matthew Walker [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 5:34 PM > To: CF-Talk > Subject: RE: Which is quicker > > > cfswitch is both quicker and more elegant. The only > downside is that it > doesn't handle dynamic values. > > Iii() is one of those functions, like evaluate(), usage of which is > generally discouraged. > > -Original Message- > From: Parker, Kevin [mailto:[EMAIL PROTECTED] > Sent: Thursday, 12 February 2004 10:30 a.m. > To: CF-Talk > Subject: Which is quicker > > Can I get a little advice on which is quicker or which is > the preferred > way > of programming - there are 8 items to select from: > > CFIF, CFCASE or IIF > > TIA! > > +++ > Kevin Parker > Web Services Manager > WorkCover Corporation > > p: 08 8233 2548 > e: [EMAIL PROTECTED] > w: www.workcover.com > +++ > > > ** > ** > This e-mail is intended for the use of the addressee only. It may > contain information that is protected by legislated confidentiality > and/or is legally privileged. If you are not the intended > recipient you > are prohibited from disseminating, distributing or copying > this e-mail. > > Any opinion expressed in this e-mail may not necessarily be > that of the > WorkCover Corporation of South Australia. Although precautions have > been taken, the sender cannot warrant that this e-mail or any files > transmitted with it are free of viruses or any other defect. > > If you have received this e-mail in error, please notify the sender > immediately by return e-mail and destroy the original e-mail and any > copies. > > ** > ** > > _ > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
Well, the Java language is incapable of doing a switch on anything except an int (or char), so you can't turn a CFSWITCH into a Java switch unless the _expression_ is an int. I'm obviously not privvy to the CF codebase, but that's a language limitation that's been there since the beginning. Or were you refering to the chaining stuff? Again, I've not seen source, but I can't think of a good reason to evaluate all the criteria when you don't have to. Same thing as short-circuit boolean operations within a single boolean _expression_. Cheers, barneyb > -Original Message- > From: Bryan Stevenson [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 2:50 PM > To: CF-Talk > Subject: Re: Which is quicker > > So Barney this has changed since CF 5 then?? > > Bryan Stevenson B.Comm. > VP & Director of E-Commerce Development > Electric Edge Systems Group Inc. > t. 250.920.8830 > e. [EMAIL PROTECTED] > > - > Macromedia Associate Partner > www.macromedia.com > - > Vancouver Island ColdFusion Users Group > Founder & Director > www.cfug-vancouverisland.com > - Original Message ----- > From: Barney Boisvert > To: CF-Talk > Sent: Wednesday, February 11, 2004 2:44 PM > Subject: RE: Which is quicker > > > Actually, they both only check until they find a match, > assuming you're > using CFELSEIF in there to bind them all togther. > > Both constructs are done as IF statements at the Java > level, so you don't > get the 'usual' benefit of a switch construct. CFSWITCH > might be faster > (particularly if the _expression_ value is expensive to > compute) if the CF > engine uses a temporary variable, but for simple > expressions, that might > actually slow things down, because doing that's an extra step to do. > > Cheers, > barneyb > > > -Original Message- > > From: Bryan Stevenson [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, February 11, 2004 2:33 PM > > To: CF-Talk > > Subject: Re: Which is quicker > > > > CFCASE will be a tad quicker > > > > Basically CFIF has to check ALL conditions where CFCASE will > > stop when it finds the correct case. > > > > Bryan Stevenson B.Comm. > > VP & Director of E-Commerce Development > > Electric Edge Systems Group Inc. > > t. 250.920.8830 > > e. [EMAIL PROTECTED] > > > > - > > Macromedia Associate Partner > > www.macromedia.com > > - > > Vancouver Island ColdFusion Users Group > > Founder & Director > > www.cfug-vancouverisland.com > > - Original Message - > > From: Parker, Kevin > > To: CF-Talk > > Sent: Wednesday, February 11, 2004 2:29 PM > > Subject: Which is quicker > > > > > > Can I get a little advice on which is quicker or which is > > the preferred way > > of programming - there are 8 items to select from: > > > > CFIF, CFCASE or IIF > > > > TIA! > > > > +++ > > Kevin Parker > > Web Services Manager > > WorkCover Corporation > > > > p: 08 8233 2548 > > e: [EMAIL PROTECTED] > > w: www.workcover.com > > +++ > > > > > > ** > > ** > > This e-mail is intended for the use of the addressee > only. It may > > contain information that is protected by legislated > confidentiality > > and/or is legally privileged. If you are not the intended > > recipient you > > are prohibited from disseminating, distributing or copying > > this e-mail. > > > > Any opinion expressed in this e-mail may not necessarily be > > that of the > > WorkCover Corporation of South Australia. Although > precautions have > > been taken, the sender cannot warrant that this e-mail > or any files > > transmitted with it are free of viruses or any other defect. > > > > If you have received this e-mail in error, please > notify the sender > > immediately by return e-mail and destroy the original > e-mail and any > > copies. > > > > ** > > ** > > > > > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
My test indicates iif() is about 400% slower. But the real issue is code readability. If you think it's more readable in any or all circumstances, I say go for it. Personally, I think this example demonstrates it is less readable. There are probably other example that show it in a better light. Here's my sample: !? #iif(i mod 2, de("!"), de("?"))# -Original Message- From: Tom Kitta [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:47 a.m. To: CF-Talk Subject: RE: Which is quicker I don't know why people don't like iif (immediate if), it is as quick as cfif and takes only one line. For simple things, like "if x < y print true else print false", I think using iif makes code shorter without sacrificing clarity and speed. If you don't believe iif is fast then I encourage you to write a small test and see for yourself. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:34 PM To: CF-Talk Subject: RE: Which is quicker cfswitch is both quicker and more elegant. The only downside is that it doesn't handle dynamic values. Iii() is one of those functions, like evaluate(), usage of which is generally discouraged. -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:30 a.m. To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legislated confidentiality and/or is legally privileged. If you are not the intended recipient you are prohibited from disseminating, distributing or copying this e-mail. Any opinion expressed in this e-mail may not necessarily be that of the WorkCover Corporation of South Australia. Although precautions have been taken, the sender cannot warrant that this e-mail or any files transmitted with it are free of viruses or any other defect. If you have received this e-mail in error, please notify the sender immediately by return e-mail and destroy the original e-mail and any copies. _ _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Which is quicker
So Barney this has changed since CF 5 then?? Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com - Original Message - From: Barney Boisvert To: CF-Talk Sent: Wednesday, February 11, 2004 2:44 PM Subject: RE: Which is quicker Actually, they both only check until they find a match, assuming you're using CFELSEIF in there to bind them all togther. Both constructs are done as IF statements at the Java level, so you don't get the 'usual' benefit of a switch construct. CFSWITCH might be faster (particularly if the _expression_ value is expensive to compute) if the CF engine uses a temporary variable, but for simple expressions, that might actually slow things down, because doing that's an extra step to do. Cheers, barneyb > -Original Message- > From: Bryan Stevenson [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 2:33 PM > To: CF-Talk > Subject: Re: Which is quicker > > CFCASE will be a tad quicker > > Basically CFIF has to check ALL conditions where CFCASE will > stop when it finds the correct case. > > Bryan Stevenson B.Comm. > VP & Director of E-Commerce Development > Electric Edge Systems Group Inc. > t. 250.920.8830 > e. [EMAIL PROTECTED] > > - > Macromedia Associate Partner > www.macromedia.com > - > Vancouver Island ColdFusion Users Group > Founder & Director > www.cfug-vancouverisland.com > - Original Message - > From: Parker, Kevin > To: CF-Talk > Sent: Wednesday, February 11, 2004 2:29 PM > Subject: Which is quicker > > > Can I get a little advice on which is quicker or which is > the preferred way > of programming - there are 8 items to select from: > > CFIF, CFCASE or IIF > > TIA! > > +++ > Kevin Parker > Web Services Manager > WorkCover Corporation > > p: 08 8233 2548 > e: [EMAIL PROTECTED] > w: www.workcover.com > +++ > > > ** > ** > This e-mail is intended for the use of the addressee only. It may > contain information that is protected by legislated confidentiality > and/or is legally privileged. If you are not the intended > recipient you > are prohibited from disseminating, distributing or copying > this e-mail. > > Any opinion expressed in this e-mail may not necessarily be > that of the > WorkCover Corporation of South Australia. Although precautions have > been taken, the sender cannot warrant that this e-mail or any files > transmitted with it are free of viruses or any other defect. > > If you have received this e-mail in error, please notify the sender > immediately by return e-mail and destroy the original e-mail and any > copies. > > ** > ** > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
I don't know why people don't like iif (immediate if), it is as quick as cfif and takes only one line. For simple things, like "if x < y print true else print false", I think using iif makes code shorter without sacrificing clarity and speed. If you don't believe iif is fast then I encourage you to write a small test and see for yourself. TK -Original Message- From: Matthew Walker [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:34 PM To: CF-Talk Subject: RE: Which is quicker cfswitch is both quicker and more elegant. The only downside is that it doesn't handle dynamic values. Iii() is one of those functions, like evaluate(), usage of which is generally discouraged. -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:30 a.m. To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legislated confidentiality and/or is legally privileged. If you are not the intended recipient you are prohibited from disseminating, distributing or copying this e-mail. Any opinion expressed in this e-mail may not necessarily be that of the WorkCover Corporation of South Australia. Although precautions have been taken, the sender cannot warrant that this e-mail or any files transmitted with it are free of viruses or any other defect. If you have received this e-mail in error, please notify the sender immediately by return e-mail and destroy the original e-mail and any copies. _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
Actually, they both only check until they find a match, assuming you're using CFELSEIF in there to bind them all togther. Both constructs are done as IF statements at the Java level, so you don't get the 'usual' benefit of a switch construct. CFSWITCH might be faster (particularly if the _expression_ value is expensive to compute) if the CF engine uses a temporary variable, but for simple expressions, that might actually slow things down, because doing that's an extra step to do. Cheers, barneyb > -Original Message- > From: Bryan Stevenson [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 11, 2004 2:33 PM > To: CF-Talk > Subject: Re: Which is quicker > > CFCASE will be a tad quicker > > Basically CFIF has to check ALL conditions where CFCASE will > stop when it finds the correct case. > > Bryan Stevenson B.Comm. > VP & Director of E-Commerce Development > Electric Edge Systems Group Inc. > t. 250.920.8830 > e. [EMAIL PROTECTED] > > - > Macromedia Associate Partner > www.macromedia.com > - > Vancouver Island ColdFusion Users Group > Founder & Director > www.cfug-vancouverisland.com > - Original Message - > From: Parker, Kevin > To: CF-Talk > Sent: Wednesday, February 11, 2004 2:29 PM > Subject: Which is quicker > > > Can I get a little advice on which is quicker or which is > the preferred way > of programming - there are 8 items to select from: > > CFIF, CFCASE or IIF > > TIA! > > +++ > Kevin Parker > Web Services Manager > WorkCover Corporation > > p: 08 8233 2548 > e: [EMAIL PROTECTED] > w: www.workcover.com > +++ > > > ** > ** > This e-mail is intended for the use of the addressee only. It may > contain information that is protected by legislated confidentiality > and/or is legally privileged. If you are not the intended > recipient you > are prohibited from disseminating, distributing or copying > this e-mail. > > Any opinion expressed in this e-mail may not necessarily be > that of the > WorkCover Corporation of South Australia. Although precautions have > been taken, the sender cannot warrant that this e-mail or any files > transmitted with it are free of viruses or any other defect. > > If you have received this e-mail in error, please notify the sender > immediately by return e-mail and destroy the original e-mail and any > copies. > > ** > ** > > [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
cfswitch is both quicker and more elegant. The only downside is that it doesn't handle dynamic values. Iii() is one of those functions, like evaluate(), usage of which is generally discouraged. -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Thursday, 12 February 2004 10:30 a.m. To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legislated confidentiality and/or is legally privileged. If you are not the intended recipient you are prohibited from disseminating, distributing or copying this e-mail. Any opinion expressed in this e-mail may not necessarily be that of the WorkCover Corporation of South Australia. Although precautions have been taken, the sender cannot warrant that this e-mail or any files transmitted with it are free of viruses or any other defect. If you have received this e-mail in error, please notify the sender immediately by return e-mail and destroy the original e-mail and any copies. _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
Re: Which is quicker
CFCASE will be a tad quicker Basically CFIF has to check ALL conditions where CFCASE will stop when it finds the correct case. Bryan Stevenson B.Comm. VP & Director of E-Commerce Development Electric Edge Systems Group Inc. t. 250.920.8830 e. [EMAIL PROTECTED] - Macromedia Associate Partner www.macromedia.com - Vancouver Island ColdFusion Users Group Founder & Director www.cfug-vancouverisland.com - Original Message - From: Parker, Kevin To: CF-Talk Sent: Wednesday, February 11, 2004 2:29 PM Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legislated confidentiality and/or is legally privileged. If you are not the intended recipient you are prohibited from disseminating, distributing or copying this e-mail. Any opinion expressed in this e-mail may not necessarily be that of the WorkCover Corporation of South Australia. Although precautions have been taken, the sender cannot warrant that this e-mail or any files transmitted with it are free of viruses or any other defect. If you have received this e-mail in error, please notify the sender immediately by return e-mail and destroy the original e-mail and any copies. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
RE: Which is quicker
cfcase / cfswitch is the desired method of choice, from what ive always been told. since the cfif have to all be evaluated for each request. tony r e v o l u t i o n w e b d e s i g n [EMAIL PROTECTED] www.revolutionwebdesign.com its only looks good to those who can see bad as well -anonymous -Original Message- From: Parker, Kevin [mailto:[EMAIL PROTECTED] Sent: Wednesday, February 11, 2004 5:30 PM To: CF-Talk Subject: Which is quicker Can I get a little advice on which is quicker or which is the preferred way of programming - there are 8 items to select from: CFIF, CFCASE or IIF TIA! +++ Kevin Parker Web Services Manager WorkCover Corporation p: 08 8233 2548 e: [EMAIL PROTECTED] w: www.workcover.com +++ This e-mail is intended for the use of the addressee only. It may contain information that is protected by legislated confidentiality and/or is legally privileged. If you are not the intended recipient you are prohibited from disseminating, distributing or copying this e-mail. Any opinion expressed in this e-mail may not necessarily be that of the WorkCover Corporation of South Australia. Although precautions have been taken, the sender cannot warrant that this e-mail or any files transmitted with it are free of viruses or any other defect. If you have received this e-mail in error, please notify the sender immediately by return e-mail and destroy the original e-mail and any copies. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]