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,
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<string, unknown>
-).version as string
+import { version } from './version'
/**
* Base class that implements some shared logic for all poolifier pools.
}
}
- /**
- * 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,