tracker issue : CF-4181256

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

ArrayEach has dramatic performance difference between CF10 and CF11+

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

Reporter/Name(from Bugbase): Justin Treher / Justin Treher (Justin Treher)

Created: 08/15/2016

Components: Performance

Versions: 11.0

Failure Type: Performance Issue

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / Most users will encounter

Locale/System: English / Win8 Server 64-bit

Vote Count: 3

Problem Description:

ArrayEach in CF11 is vastly different in performance to ArrayEach in CF10.

Steps to Reproduce:

<cfscript>
// test the performance of iterating through an array
// Array converted to ArrayList to pass by reference
// Regular array in CF
// using standard for loop
// Compare CF 10 vs CF11 and CF2016
// CF10 is much faster than the others


// setup our test data
foo = [];

for( i = 1; i<10000; i++){
    foo[i] = i;
}


// test 1 : Using ArrayList and ArrayEach
startTimer();

asList = CreateObject( "java", "java.util.ArrayList").init( foo ); 

ArrayEach( asList, function( e ){
   var shoe = asList[e];
});

stopTimer();

startTimer();

ArrayEach( foo, function( e ){
    var shoe = foo[e];
});

stopTimer();

startTimer();

size = ArrayLen( foo );

for( i=1; i<=size; i++){
    shoe = foo[foo[i]];
}

stopTimer();

function startTimer(){
    variables.start = getTickCount();
}

function stopTimer(){
    WriteOutput( getTickCount()-variables.start & "<br>");
}
</cfscript>

Actual Result:

Slowness on CF11

Expected Result:

Same performance as CF10

Any Workarounds:

Convert your array to ArrayList first.

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

Watson Bug ID:	4181256

External Customer Info:
External Company:  
External Customer Name: Justin Treher
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Def should be looked at. Something must be afoot here?
Vote by External U.
2030 | August 15, 2016 02:52:02 PM GMT
This is *significantly* slower in CF11 and CF2016
Vote by External U.
2031 | August 15, 2016 02:56:01 PM GMT
Here is a gist for fun: http://trycf.com/gist/ef27d1265ed5dd7454b63386accd9c0f/acf2016?theme=monokai (use the settings cog to change the engine around)
Comment by External U.
2028 | August 15, 2016 03:24:08 PM GMT
Slower is not good...
Vote by External U.
2032 | August 15, 2016 04:22:41 PM GMT
Since CF11, Coldfusion passes an additional array instanxce as third parameter to the callback function to collect the final result. In the bellow example, city name is being converted to uppercase by itereating over the passed array. Example, <cfscript> cityArray=["london","new York","paris","tokyo","Barcelona"]; function printArray(city,index,cityArray) { cityArray[index] = uppercase(city); } WriteOutput("The original array is:"); WriteDump(cityArray); ArrayEach(cityArray,printArray); WriteOutput("The new array is:"); WriteDump(cityArray); </cfscript> As the resultant array is being passed in each and every callabck iteration, it has impacted its performance. To improve the performance we had to drop the new functionality. But we see the enhanced functionality is adding significant value to ArrayEach function and hence we will not do anything here.
Comment by Awdhesh K.
2029 | September 26, 2016 12:14:14 AM GMT