import type { AbstractPoolWorker } from '../abstract-pool-worker'
import type { IPoolInternal } from '../pool-internal'
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
+import type { RequiredStatistics } from './selection-strategies-types'
/**
* Task run time.
Data,
Response
> extends AbstractWorkerChoiceStrategy<Worker, Data, Response> {
+ /** @inheritDoc */
+ public requiredStatistics: RequiredStatistics = {
+ runTime: true
+ }
+
/**
* Worker index where the previous task was submitted.
*/
>()
/**
- * Constructs a worker choice strategy that selects based a weighted round robin scheduling algorithm.
+ * Constructs a worker choice strategy that selects with a weighted round robin scheduling algorithm.
*
* @param pool The pool instance.
*/
private computeWorkerWeight () {
let cpusCycleTimeWeight = 0
- for (let cpu = 0; cpu < cpus().length; cpu++) {
+ for (const cpu of cpus()) {
// CPU estimated cycle time
- const numberOfDigit = cpus()[cpu].speed.toString().length - 1
- const cpuCycleTime = 1 / (cpus()[cpu].speed / Math.pow(10, numberOfDigit))
+ const numberOfDigit = cpu.speed.toString().length - 1
+ const cpuCycleTime = 1 / (cpu.speed / Math.pow(10, numberOfDigit))
cpusCycleTimeWeight += cpuCycleTime * Math.pow(10, numberOfDigit)
}
return cpusCycleTimeWeight / cpus().length