Following 3 test conditions:
<cfscript>
start = getTickCount();
</cfscript>
<!--- Test 1 --->
<!--- <cfset var2 = replace(application.var1, "@", "_")> --->
<!--- Test 2 --->
<!---<cfset var2 = rereplace(application.var1, "@", "_")> --->
<!--- Test 3 --->
<cfset var2 = listchangedelims(application.var1, "_", "@")>
<cfscript>
totalTime = getTickCount() - start;
</cfscript>
<cfoutput>time: #totalTime#</cfoutput>
Where application.var1 is a 50,000 repeat concatenation of "[EMAIL PROTECTED]".
Results on average over 5 runs for each:
replace: 40.2 ms
reReplace: 94 ms
listchangedelims: 128.2 ms
simple replace seems the way to go?
On 9/6/06, Adrian Lynch <[EMAIL PROTECTED]> wrote:
> I'm not normally one to jump on the "this is faster" bandwagon, and in this
> case I don't know for sure that it is faster, although it probably is, but
> Replace is likely to be quicker than REReplace.
>
> Does anyone know for sure?
>
> Adrian
>
> -----Original Message-----
> From: Vohra, Sandeep Singh [mailto:[EMAIL PROTECTED]
> Sent: 06 September 2006 04:11
> To: CF-Newbie
> Subject: RE: How to Truncate?
>
>
> Please try this:
>
> Change the Path if you wish using
> #GetFileFromPath(GetCurrentTemplatePath())# and replace functions but
> for hard coded stuff here's the code
> -----------------------------------------------------------------
> <cfset strTrunct = "[EMAIL PROTECTED]">
>
> <cfset strTruncated = #ReReplace(strTrunct,"@","_")#>
>
> <cfoutput>#strTruncated#</cfoutput>
>
> <cffile action = "write" file = "D:\\inetpub\wwwroot\#strTruncated#.txt"
> output="Created by Gary Strommen" >
> -----------------------------------------------------------------
>
> Thanks.
>
> -Sandy Vohra
> -----Original Message-----
> From: Gary Strommen [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 05, 2006 8:52 PM
> To: CF-Newbie
> Subject: How to Truncate?
>
> Goal: I want to take the user's email and make it part of the file
> name. However, having the "@" sign in a file name is not desired. I
> want to write code that will take the user's email and change the "@" to
> an underscore. I think that the truncate command might help here but I
> am having a difficult time finding information on how to use it.
>
> Any help would be great.
> Thanks!
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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-Newbie/message.cfm/messageid:2032
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15