ArrayMin

Description

Array minimum function.

Returns

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

syntax

arrayMin(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]
       minVal=ArrayMin(myArray)
       WriteOutput(minVal)// Returns -43
</cfscript>

Using parallelization

<cfscript> 
 for(i=1;i<=1001;i++){ 
  arr[i] = i*2; 
  if(i == 554) 
   arr[i]= -2147483648  
 } 
 //writedump(arr) 
 //writeoutput(arr.min()) 
  
 t_start=GetTickCount() 
writeoutput(arraymin(arr,true,5))  
 t_end=GetTickCount() 
 writeoutput("<br>Time taken with 5 threads:" &  t_end-t_start) 
  
  
 t_start=GetTickCount() 
writeoutput(arr.min(true,10)) 
 t_end=GetTickCount() 
 writeoutput("<br>Time taken with 10 threads:" &  t_end-t_start) 
  
 t_start=GetTickCount() 
writeoutput(arraymin(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.min()) 
 t_end=GetTickCount() 
 writeoutput("<br>Time taken with no parallel:" &  t_end-t_start) 
  
</cfscript>

 Adobe

Get help faster and easier

New user?