CpuCoreCounter
in package
Table of Contents
Properties
- $count : positive-int|null
- $finders : array<int, CpuCoreFinder>
Methods
- __construct() : mixed
- getAvailableForParallelisation() : ParallelisationResult
- getCount() : positive-int
- getCountWithFallback() : positive-int
- getFinderAndCores() : CpuCoreFinder, positive-int}
- getKubernetesLimit() : positive-int|null
- trace() : string
- This method is mostly for debugging purposes.
- checkCountLimit() : void
- checkLoadLimit() : void
- checkSystemLoadAverage() : void
- findCount() : positive-int
Properties
$count
private
positive-int|null
$count
$finders
private
array<int, CpuCoreFinder>
$finders
Methods
__construct()
public
__construct([array<int, CpuCoreFinder>|null $finders = null ]) : mixed
Parameters
- $finders : array<int, CpuCoreFinder>|null = null
getAvailableForParallelisation()
public
getAvailableForParallelisation([positive-int|0 $reservedCpus = 0 ][, int|null $countLimit = null ][, float|null $loadLimit = null ][, float|null $systemLoadAverage = 0.0 ]) : ParallelisationResult
Parameters
- $reservedCpus : positive-int|0 = 0
-
Number of CPUs to reserve. This is useful when you want to reserve some CPUs for other processes. If the main process is going to be busy still, you may want to set this value to 1.
- $countLimit : int|null = null
- $loadLimit : float|null = null
-
Element of [0., 1.]. Percentage representing the amount of cores that should be used among the available resources. For instance, if set to 0.7, it will use 70% of the available cores, i.e. if 1 core is reserved, 11 cores are available and 5 are busy, it will use 70% of (11-1-5)=5 cores, so 3 cores. Set this parameter to null to skip this check. Beware that 1 does not mean "no limit", but 100% of the available resources, i.e. with the previous example, it will return 5 cores. How busy is the system is determined by the system load average (see $systemLoadAverage).
- $systemLoadAverage : float|null = 0.0
-
The system load average. If passed, it will use this information to limit the available cores based on the available resources. For instance, if there is 10 cores but 3 are busy, then only 7 cores will be considered for further calculation. If set to
null, it will usesys_getloadavg()to check the load of the system in the past minute. You can otherwise pass an arbitrary value. Should be a positive float.
Tags
Return values
ParallelisationResultgetCount()
public
getCount() : positive-int
Tags
Return values
positive-intgetCountWithFallback()
public
getCountWithFallback(positive-int $fallback) : positive-int
Parameters
- $fallback : positive-int
Return values
positive-intgetFinderAndCores()
public
getFinderAndCores() : CpuCoreFinder, positive-int}
Tags
Return values
CpuCoreFinder, positive-int}getKubernetesLimit()
public
static getKubernetesLimit() : positive-int|null
Return values
positive-int|nulltrace()
This method is mostly for debugging purposes.
public
trace() : string
Return values
stringcheckCountLimit()
private
static checkCountLimit(int|null $countLimit) : void
Parameters
- $countLimit : int|null
checkLoadLimit()
private
static checkLoadLimit(float|null $loadLimit) : void
Parameters
- $loadLimit : float|null
checkSystemLoadAverage()
private
static checkSystemLoadAverage(float|null $systemLoadAverage) : void
Parameters
- $systemLoadAverage : float|null
findCount()
private
findCount() : positive-int