ArrayMax

Description

Array maximum function.

Returns

The largest numeric value in an array. If the array parameter value is an empty array, returns zero.

Category

Array functions

HISTORY

ColdFusion (2021 release): Introduced the following parameters:

  • parallel
  • maxThreadCount

Function syntax

arrayMax(array [, parallel] [, maxThreadCount])

Parameters

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.

Example

<cfscript>
       myArray=[23,76,1,-43,9,112]
       maxVal=ArrayMax(myArray)
       WriteOutput(maxVal)// Returns 112
</cfscript>

Using parallelization

<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>

 Adobe

Dapatkan bantuan lebih cepat dan lebih mudah

Pengguna baru?

Adobe MAX 2024

Adobe MAX
Konferensi Kreativitas

14–16 Oktober Miami Beach dan online

Adobe MAX

Konferensi Kreativitas

14–16 Oktober Miami Beach dan online

Adobe MAX 2024

Adobe MAX
Konferensi Kreativitas

14–16 Oktober Miami Beach dan online

Adobe MAX

Konferensi Kreativitas

14–16 Oktober Miami Beach dan online