Difference appears to be nil. Initial compile time was slighty higher on the
"#var1#123" method (62ms vs 47 ms for var1 & "123"). Running each set of
code 10 times in a row averaged between 0 and 16ms for each.
Here's some code for testing:
<cfset var1 = "abc">
<!---
<cfset foo = "#var1#123">
<cfset foo = var1 & "123">
--->
<!--- Setup timing test --->
<cfset iterationCount = 1000>
<!--- Time an empty loop with this many iterations --->
<cfset tickBegin = GetTickCount()>
<cfloop Index = i From = 1 To = #iterationCount#>
<cfset foo = var1 & "123">
</cfloop>
<cfset tickEnd = GetTickCount()>
<cfset loopTime = tickEnd - tickBegin>
<!--- Report --->
<cfoutput>Loop time (#iterationCount# iterations) was: #loopTime#
milliseconds</cfoutput>
<!----------------//------
andy matthews
web developer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--------------//--------->
-----Original Message-----
From: James Reily [mailto:[EMAIL PROTECTED]
Sent: Monday, January 30, 2006 12:48 PM
To: CF-Talk
Subject: Which string operation is faster?
Which of these executes faster, or do they each take the same amount of
processing? Are they equivalent "under the hood"?
<cfset foo = "#var1#123">
or
<cfset foo = var1 & "123">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:230766
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54