House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Optimizing Performance help

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mark W. Breneman
05/20/2003 05:07 PM

I am looking to optimize this chunk of code.  What it should do is trim any leading or trailing spaces and to also define any form.vars that do not exist. i.e check boxes.  I have optimized it as much as I know how.  Can this be made faster or better? <cfloop index="i" list="Firstname,lastname, address1,etc....">   <!--- sets all blank raidio and check boxes to "" to prevent errors --->   <cfparam name="form.#Trim(i)#" default=""><CFSET "form.#Trim(i)#" = form[trim(i)]> </cfloop> Mark W. Breneman -Macromedia Certified ColdFusion Developer -Network / Web Server Administrator   Vivid Media   mark@vividmedia.com   www.vividmedia.com   608.270.9770

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Bryan F. Hogan
05/20/2003 05:09 PM

<cfloop collection="#FORM#" item="idx">   <cfset FORM['idx']=Trim(FORM['idx'])> </cfloop> I am looking to optimize this chunk of code.  What it should do is trim any leading or trailing spaces and to also define any form.vars that do not exist. i.e check boxes.  I have optimized it as much as I know how.  Can this be made faster or better? <cfloop index="i" list="Firstname,lastname, address1,etc....">   <!--- sets all blank raidio and check boxes to "" to prevent errors --->   <cfparam name="form.#Trim(i)#" default=""><CFSET "form.#Trim(i)#" = form[trim(i)]> </cfloop> Mark W. Breneman -Macromedia Certified ColdFusion Developer -Network / Web Server Administrator   Vivid Media   mark@vividmedia.com   www.vividmedia.com   608.270.9770

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mark W. Breneman
05/20/2003 05:29 PM

I don't think that will do what I am looking for. I think what you are trying to show here is to loop through the form structure.  This will not define a blank form.var for a radio button that was not selected on the "submitting page". But, this does make me wonder if setting the values in the structure would be faster then <CFSET "form.#Trim(i)#"... Any ideas? Thanks Mark W. Breneman -Macromedia Certified ColdFusion Developer -Network / Web Server Administrator   Vivid Media   mark@vividmedia.com   www.vividmedia.com   608.270.9770 <cfloop collection="#FORM#" item="idx">   <cfset FORM['idx']=Trim(FORM['idx'])> </cfloop> I am looking to optimize this chunk of code.  What it should do is trim any leading or trailing spaces and to also define any form.vars that do not exist. i.e check boxes.  I have optimized it as much as I know how.  Can this be made faster or better? <cfloop index="i" list="Firstname,lastname, address1,etc....">   <!--- sets all blank raidio and check boxes to "" to prevent errors --->   <cfparam name="form.#Trim(i)#" default=""><CFSET "form.#Trim(i)#" = form[trim(i)]> </cfloop> Mark W. Breneman -Macromedia Certified ColdFusion Developer -Network / Web Server Administrator   Vivid Media   mark@vividmedia.com   www.vividmedia.com   608.270.9770

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Philip Arnold
05/20/2003 05:39 PM

----- Excess quoted text cut - see Original Post for more ----- Get rid of the list and convert it to an array, they're faster for loops That'll speed it up the longer the list it - loops over long lists are HORRIBLY slow Not to mention that that your CFSET does nothing really Oh, and since you're only making sure that the variables empty, don't use CFPARAM, it's slower than doing it by code Also, do it in CFSCRIPT HTH

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mark W. Breneman
05/20/2003 05:50 PM

The cfset is where the trimming happens for all form values that do already exist. So, something like <cfif not StructKeyExists(form, i) ><CFSET "form.#Trim(i)#" = ""></cfif> is faster than <cfparam name="form.#Trim(i)#" default=""> ? CFscrip is the next step. Thanks Mark W. Breneman -Macromedia Certified ColdFusion Developer -Network / Web Server Administrator   Vivid Media   mark@vividmedia.com   www.vividmedia.com   608.270.9770 ----- Excess quoted text cut - see Original Post for more ----- Get rid of the list and convert it to an array, they're faster for loops That'll speed it up the longer the list it - loops over long lists are HORRIBLY slow Not to mention that that your CFSET does nothing really Oh, and since you're only making sure that the variables empty, don't use CFPARAM, it's slower than doing it by code Also, do it in CFSCRIPT HTH

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Philip Arnold
05/20/2003 06:11 PM

----- Excess quoted text cut - see Original Post for more ----- Actually, the CFSET doesn't do that <CFSET "form.#Trim(i)#" = form[trim(i)]> There should be a Trim() outside of the form[] But putting it in CFSCRIPT should look like this; FieldArray=ListToArray("Firstname,lastname, address1,etc...."); For (i=1; I lte ArrayLen(FieldArray); i=i+1) {  j=FieldArray[i];   if (not isDefined("form.#j#"))   {  form[j]="";   }   form[j]=Trim(form[j]); } That should do it perfectly

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mark W. Breneman
05/20/2003 06:29 PM

<egg on red face> Yes, you are correct. That cfset should have had a Trim() outside of the form[].  I missed that when I wrote the code for the email. That is very embarrassing!  Sorry </egg on red face> CFscript... Thank you very much... I was not expecting (nor looking for) anyone to convert it to cfscrip for me.  That was way beyond the "call of duty"... Thanks. Mark W. Breneman -Macromedia Certified ColdFusion Developer -Network / Web Server Administrator   Vivid Media   mark@vividmedia.com   www.vividmedia.com   608.270.9770 ----- Excess quoted text cut - see Original Post for more ----- Actually, the CFSET doesn't do that <CFSET "form.#Trim(i)#" = form[trim(i)]> There should be a Trim() outside of the form[] But putting it in CFSCRIPT should look like this; FieldArray=ListToArray("Firstname,lastname, address1,etc...."); For (i=1; I lte ArrayLen(FieldArray); i=i+1) {  j=FieldArray[i];   if (not isDefined("form.#j#"))   {  form[j]="";   }   form[j]=Trim(form[j]); } That should do it perfectly

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Brunt
05/20/2003 05:58 PM

Just jumping on here, cfparam used on a large scale basis is as has been stated here, very slow.  We had a client that CFPARAM'ed 100's of vars with every request and the slowdown in performance was pretty severe.  Just my 2 cents (sorry pence <I came from England> [good job I did not say francs!];O) Kind Regards - Mike Brunt Original Message ----------------------- The cfset is where the trimming happens for all form values that do already exist. So, something like <cfif not StructKeyExists(form, i) ><CFSET "form.#Trim(i)#" = ""></cfif> is faster than <cfparam name="form.#Trim(i)#" default=""> ? CFscrip is the next step. Thanks Mark W. Breneman -Macromedia Certified ColdFusion Developer -Network / Web Server Administrator   Vivid Media   mark@vividmedia.com   www.vividmedia.com   608.270.9770 ----- Excess quoted text cut - see Original Post for more ----- Get rid of the list and convert it to an array, they're faster for loops That'll speed it up the longer the list it - loops over long lists are HORRIBLY slow Not to mention that that your CFSET does nothing really Oh, and since you're only making sure that the variables empty, don't use CFPARAM, it's slower than doing it by code Also, do it in CFSCRIPT HTH

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mark W. Breneman
05/20/2003 06:10 PM

That is exactly the info I am looking for! The chunk of code that I have submitted is important to be optimized, but what I am really "fishing" for is info for how to optimize stuff like this. I deal with large forms on a daily basis and I have written several server side error checking and validation snippets that I use on every form. Now I am just trying to take these snippets to the next level and make them better. Thanks! Mark W. Breneman -Macromedia Certified ColdFusion Developer -Network / Web Server Administrator   Vivid Media   mark@vividmedia.com   www.vividmedia.com   608.270.9770 Just jumping on here, cfparam used on a large scale basis is as has been stated here, very slow.  We had a client that CFPARAM'ed 100's of vars with every request and the slowdown in performance was pretty severe.  Just my 2 cents (sorry pence <I came from England> [good job I did not say francs!];O) Kind Regards - Mike Brunt Original Message ----------------------- The cfset is where the trimming happens for all form values that do already exist. So, something like <cfif not StructKeyExists(form, i) ><CFSET "form.#Trim(i)#" = ""></cfif> is faster than <cfparam name="form.#Trim(i)#" default=""> ? CFscrip is the next step. Thanks Mark W. Breneman -Macromedia Certified ColdFusion Developer -Network / Web Server Administrator   Vivid Media   mark@vividmedia.com   www.vividmedia.com   608.270.9770 ----- Excess quoted text cut - see Original Post for more ----- Get rid of the list and convert it to an array, they're faster for loops That'll speed it up the longer the list it - loops over long lists are HORRIBLY slow Not to mention that that your CFSET does nothing really Oh, and since you're only making sure that the variables empty, don't use CFPARAM, it's slower than doing it by code Also, do it in CFSCRIPT HTH


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 23, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference