Parameter
You can also set the maximum thread count in ColdFusion Administrator. Click Server Settings > Settings and specify the number of threads in Default Maximum Thread Count For Parallel Functions.
Array maximum function.
The largest numeric value in an array. If the array parameter value is an empty array, returns zero.
HISTORY
ColdFusion (2021 release): Introduced the following parameters:
arrayMax(array [, parallel] [, maxThreadCount]) |
|
Parameter |
Description |
|
array |
Name of an array |
|
parallel |
True if you want to enable parallel programming. |
|
maxThreadCount |
The number of threads the function can execute. The number of threads must be between 1-50. If the value exceeds 50, there is an exception. |
<cfscript>
myArray=[23,76,1,-43,9,112]
maxVal=ArrayMax(myArray)
WriteOutput(maxVal)// Returns 112
</cfscript>
<cfscript>
for(i=1;i<=1001;i++){
arr[i] = i*2;
if(i == 554)
arr[i]= 2147483648
}
//writedump(arr)
//writeoutput(arr.max())
t_start=GetTickCount()
writeoutput(arraymax(arr,true,5))
t_end=GetTickCount()
writeoutput("<br>Time taken with 5 threads:" & t_end-t_start)
t_start=GetTickCount()
writeoutput(arr.max(true,10))
t_end=GetTickCount()
writeoutput("<br>Time taken with 10 threads:" & t_end-t_start)
t_start=GetTickCount()
writeoutput(arraymax(array=arr,parallel=true,maxthreadcount=20))
t_end=GetTickCount()
writeoutput("<br>Time taken with 20 threads:" & t_end-t_start)
t_start=GetTickCount()
writeoutput(arr.max())
t_end=GetTickCount()
writeoutput("<br>Time taken with no parallel:" & t_end-t_start)
</cfscript>
Sign in to your account