X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fpools%2Fabstract-pool.ts;h=283b04d682b4a656b6a430a78714a9ae52582e72;hb=f294681c4244effd6671e9d3534bf54bbf122d7a;hp=03f8c199be642dda1cac20171d0b2410ef73d1c3;hpb=23ccf9d796ac950710863515ff45612a0456931d;p=poolifier.git diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 03f8c199..283b04d6 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -1,6 +1,5 @@ import crypto from 'node:crypto' import { performance } from 'node:perf_hooks' -import { readFileSync } from 'node:fs' import type { MessageValue, PromiseResponseWrapper } from '../utility-types' import { DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS, @@ -39,12 +38,7 @@ import { type WorkerChoiceStrategyOptions } from './selection-strategies/selection-strategies-types' import { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context' - -const version = ( - JSON.parse( - readFileSync(new URL('../../package.json', import.meta.url), 'utf8') - ) as Record -).version as string +import { version } from './version' /** * Base class that implements some shared logic for all poolifier pools. @@ -306,22 +300,14 @@ export abstract class AbstractPool< } } - /** - * Gets the pool run time. - * - * @returns The pool run time in milliseconds. - */ - private get runTime (): number { - return performance.now() - this.startTimestamp - } - /** * Gets the approximate pool utilization. * * @returns The pool utilization. */ private get utilization (): number { - const poolRunTimeCapacity = this.runTime * this.maxSize + const poolRunTimeCapacity = + (performance.now() - this.startTimestamp) * this.maxSize const totalTasksRunTime = this.workerNodes.reduce( (accumulator, workerNode) => accumulator + workerNode.usage.runTime.aggregate,