Rob

What CPU are you running this on?

My times are about twice as long ( the 3:1 ratio is approx the same).

I was surprised because My 800MHz Mac usually runs faster than most  
CPUs that are twice the MHz.

Below is the exact routine I used.

Dick

=========================================================
<cfscript>
   start=GetTickCount();

   sb_filler = createObject("java","java.lang.StringBuffer");
   for(x=0; x lte 65535; x=x+1){
     sb_filler.append(chr(x));
   }
   end=GetTickCount();
</cfscript>
<cfoutput>
   <code>
   <br>String Buffer Duration...#end-start#........Original Average:  
5609 ms
   </code>
</cfoutput>

<cfscript>
   start1=GetTickCount();

   s_filler = "";
   for(x=0; x lte 65535; x=x+1){
     s_filler = s_filler & chr(x);
   }
   end1=GetTickCount();

</cfscript>
<cfoutput>
   <code>
   <br>String Duration..........#end1-start1#........Original Average:  
17250 ms
   </code>
</cfoutput>
=========================================================

On Wednesday, November 27, 2002, at 12:16 PM, Rob Rohan wrote:

> Ok, so in Java using a String can cost a lot when you have to append  
> over
> and over (because I think it makes a new String object for each  
> iteration) -
> to fix this you're supposed to use a string buffer. So I decided to try
> using a string buffer in MX to see if I could get a bit of a  
> performance
> gain... check it out
>
> with string buffer:
> <cfscript>
>       sb_filler = createObject("java","java.lang.StringBuffer");
>
>       for(x=0; x lte 65535; x=x+1){
>               sb_filler.append(chr(x));
>       }
> </cfscript>
> <cfoutput>#sb_filler.toString()#</cfoutput>
>
> ** Average: 5609 ms **
>
>
> normal string
> <cfscript>
>       s_filler = "";
>
>       for(x=0; x lte 65535; x=x+1){
>               s_filler = s_filler & chr(x);
>       }
>
> </cfscript>
> <cfoutput>#s_filler#</cfoutput>
>
> ** Average: 17250 ms **
>
> You wont see a bit performance in crease with little appends, but it  
> makes a
> difference with big ones.
>
>
> (I can believe Macromedia doesn't want me to work for them :-/ jezzz)
> Rob
>
> http://treebeard.sourceforge.net
> http://ruinworld.sourceforge.net
> Scientia Est Potentia
>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Reply via email to