From: Jérôme Benoit Date: Wed, 5 Jul 2023 07:13:26 +0000 (+0200) Subject: feat: add task statistics to pool info: runTime and waitTime X-Git-Tag: v2.6.9~13 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1dcf8b7bde75702819789220dbb05787ab6eff35;p=poolifier.git feat: add task statistics to pool info: runTime and waitTime Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 596b7f4d..df3eeb30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add minimum and maximum to internal measurement statistics. +- Add `runTime` and `waitTime` to pool information. ## [2.6.8] - 2023-07-03 diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 95df53b2..fc703d14 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -297,7 +297,37 @@ export abstract class AbstractPool< (accumulator, workerNode) => accumulator + workerNode.usage.tasks.failed, 0 - ) + ), + ...(this.workerChoiceStrategyContext.getTaskStatisticsRequirements() + .runTime.aggregate && { + runTime: { + minimum: Math.min( + ...this.workerNodes.map( + workerNode => workerNode.usage.runTime.minimum + ) + ), + maximum: Math.max( + ...this.workerNodes.map( + workerNode => workerNode.usage.runTime.maximum + ) + ) + } + }), + ...(this.workerChoiceStrategyContext.getTaskStatisticsRequirements() + .waitTime.aggregate && { + waitTime: { + minimum: Math.min( + ...this.workerNodes.map( + workerNode => workerNode.usage.waitTime.minimum + ) + ), + maximum: Math.max( + ...this.workerNodes.map( + workerNode => workerNode.usage.waitTime.maximum + ) + ) + } + }) } } diff --git a/src/pools/pool.ts b/src/pools/pool.ts index bb28535b..15654803 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -86,6 +86,14 @@ export interface PoolInfo { queuedTasks: number maxQueuedTasks: number failedTasks: number + runTime?: { + minimum: number + maximum: number + } + waitTime?: { + minimum: number + maximum: number + } } /**