From 1dcf8b7bde75702819789220dbb05787ab6eff35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 5 Jul 2023 09:13:26 +0200 Subject: [PATCH] feat: add task statistics to pool info: runTime and waitTime MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- CHANGELOG.md | 1 + src/pools/abstract-pool.ts | 32 +++++++++++++++++++++++++++++++- src/pools/pool.ts | 8 ++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) 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 + } } /** -- 2.34.1