tracker issue : CF-4190744

select a category, or use search below
(searches all categories and all time range)

Performances issue on String Underlying Java Methods

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Eric Esquivel / Eric Esquivel (Eric Esquivel)

Created: 09/19/2016

Components: Performance

Versions: 2016,11.0

Failure Type: Performance Issue

Found In Build/Fixed In Build: CF11_Final / 307670

Priority/Frequency: Normal / Few users will encounter

Locale/System: ALL / Win 2008 Server R2 64 bit

Vote Count: 0

Problem Description:

Using String Underlying Java Method for String impact the performance of web page processing if they are used. With the "native" method (function) it has much better performances.

Steps to Reproduce:

<cfset myString= "test">
<cftimer label="toUpperCase">
<cfloop from="1" to="10000" index="i">
<cfset myString.toUpperCase()>
<cftimer label="uCase">
<cfloop from="1" to="10000" index="i">
<cfset uCase(myString)>
<cftimer label="reReplace">
<cfloop from="1" to="10000" index="i">
	<cfset reReplace(myString,"\\([^\\]+)$","","all") />
<cftimer label="replaceAll">
<cfloop from="1" to="10000" index="i">
	<cfset myString.replaceAll("\\([^\\]+)$","") />

Actual Result:

[2520ms] toUpperCase
[4ms] uCase

Expected Result:

similar speed to process the same operation

Any Workarounds:
Use the "native" method

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4190744

External Customer Info:
External Company:  
External Customer Name: Eric Esquivel
External Customer Email:  
External Test Config: My Hardware and Environment details:

Coldfusion 11, similar issue with CF2016



overhead of java reflection
Comment by External U.
1781 | September 20, 2016 10:06:55 AM GMT
the diff. b/w toUpperCase and ucase seems to have come down. samples from cf18 and cf16u6 on winx64. --------------------------------------------------- 2018,0,0,307670 --------------------------------------------------- toUpperCase: 20 uCase: 8 reReplace: 287 replaceAll: 79 toUpperCase: 25 uCase: 3 reReplace: 62 --------------------------------------------------- toUpperCase: 15 uCase: 3 reReplace: 18 replaceAll: 38 toUpperCase: 32 uCase: 1 reReplace: 26 --------------------------------------------------- 2016,0,06,308055 -------------------------------------------- toUpperCase: 82 uCase: 7 reReplace: 348 replaceAll: 114 toUpperCase: 24 uCase: 4 reReplace: 52 -------------------------------------------- toUpperCase: 23 uCase: 6 reReplace: 52 replaceAll: 80 toUpperCase: 23 uCase: 4 reReplace: 47 -------------------------------------------- toUpperCase: 28 uCase: 6 reReplace: 47 replaceAll: 36 toUpperCase: 20 uCase: 3 reReplace: 130
Comment by Piyush K.
27563 | April 19, 2018 07:05:07 AM GMT
Eric, In CFML, myString.toUpperCase() would inherently be expensive, because the datatype of myString is not known to CF. But we did made some improvements in the way we handle generic strings. You should see a smaller delta now.
Comment by Piyush K.
27564 | April 23, 2018 09:43:34 AM GMT