X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fselection-strategies%2Fabstract-worker-choice-strategy.ts;h=a4455d28a8e33c5bac1bceaf679b8feab5de533b;hb=f6b641d651fdd5114bcd63bf1c991955d5b7d3eb;hp=c3fb28c4f1e162185f65e08029c886e8df826d99;hpb=0509fd43c1e920aed11ba50293062eaf167bef44;p=poolifier.git diff --git a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts index c3fb28c4..a4455d28 100644 --- a/src/pools/selection-strategies/abstract-worker-choice-strategy.ts +++ b/src/pools/selection-strategies/abstract-worker-choice-strategy.ts @@ -87,6 +87,20 @@ export abstract class AbstractWorkerChoiceStrategy< return this.findFirstFreeWorkerNodeKey() } + /** + * Gets the worker task run time. + * If the required statistics are `avgRunTime`, the average run time is returned. + * If the required statistics are `medRunTime`, the median run time is returned. + * + * @param workerNodeKey - The worker node key. + * @returns The worker task run time. + */ + protected getWorkerTaskRunTime (workerNodeKey: number): number { + return this.requiredStatistics.medRunTime + ? this.pool.workerNodes[workerNodeKey].tasksUsage.medRunTime + : this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime + } + /** * Finds the first free worker node key based on the number of tasks the worker has applied. *