## [Unreleased]
+### Added
+
+- Add Event Loop Utilization (ELU) statistics to worker tasks usage.
+
+### Changed
+
+- Compute statistics at the worker level only if needed.
+
## [2.5.3] - 2023-06-04
### Changed
export { WorkerChoiceStrategies } from './pools/selection-strategies/selection-strategies-types'
export type {
IWorkerChoiceStrategy,
- RequiredStatistics,
+ TaskStatistics,
WorkerChoiceStrategy,
WorkerChoiceStrategyOptions
} from './pools/selection-strategies/selection-strategies-types'
export { KillBehaviors } from './worker/worker-options'
export type { KillBehavior, WorkerOptions } from './worker/worker-options'
export type {
- Draft,
- MessageValue,
- PromiseResponseWrapper,
TaskFunctions,
WorkerAsyncFunction,
WorkerFunction,
WorkerSyncFunction
+} from './worker/worker-functions'
+export type {
+ Draft,
+ MessageValue,
+ PromiseResponseWrapper
} from './utility-types'
export type { CircularArray } from './circular-array'
export type { Queue } from './queue'
this.enqueueTask = this.enqueueTask.bind(this)
this.checkAndEmitEvents = this.checkAndEmitEvents.bind(this)
- this.setupHook()
-
- for (let i = 1; i <= this.numberOfWorkers; i++) {
- this.createAndSetupWorker()
- }
-
if (this.opts.enableEvents === true) {
this.emitter = new PoolEmitter()
}
this.opts.workerChoiceStrategy,
this.opts.workerChoiceStrategyOptions
)
+
+ this.setupHook()
+
+ for (let i = 1; i <= this.numberOfWorkers; i++) {
+ this.createAndSetupWorker()
+ }
}
private checkFilePath (filePath: string): void {
): void {
this.checkValidWorkerChoiceStrategy(workerChoiceStrategy)
this.opts.workerChoiceStrategy = workerChoiceStrategy
+ this.workerChoiceStrategyContext.setWorkerChoiceStrategy(
+ this.opts.workerChoiceStrategy
+ )
+ if (workerChoiceStrategyOptions != null) {
+ this.setWorkerChoiceStrategyOptions(workerChoiceStrategyOptions)
+ }
for (const workerNode of this.workerNodes) {
this.setWorkerNodeTasksUsage(workerNode, {
ran: 0,
error: 0,
elu: undefined
})
- }
- this.workerChoiceStrategyContext.setWorkerChoiceStrategy(
- this.opts.workerChoiceStrategy
- )
- if (workerChoiceStrategyOptions != null) {
- this.setWorkerChoiceStrategyOptions(workerChoiceStrategyOptions)
+ this.setWorkerStatistics(workerNode.worker)
}
}
/** @inheritDoc */
public async execute (data?: Data, name?: string): Promise<Response> {
- const submissionTimestamp = performance.now()
+ const timestamp = performance.now()
const workerNodeKey = this.chooseWorkerNode()
const submittedTask: Task<Data> = {
name,
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
data: data ?? ({} as Data),
- submissionTimestamp,
+ timestamp,
id: crypto.randomUUID()
}
const res = new Promise<Response>((resolve, reject) => {
workerTasksUsage: TasksUsage,
message: MessageValue<Response>
): void {
- if (this.workerChoiceStrategyContext.getRequiredStatistics().runTime) {
+ if (this.workerChoiceStrategyContext.getTaskStatistics().runTime) {
workerTasksUsage.runTime += message.runTime ?? 0
if (
- this.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime &&
+ this.workerChoiceStrategyContext.getTaskStatistics().avgRunTime &&
workerTasksUsage.ran !== 0
) {
workerTasksUsage.avgRunTime =
workerTasksUsage.runTime / workerTasksUsage.ran
}
if (
- this.workerChoiceStrategyContext.getRequiredStatistics().medRunTime &&
+ this.workerChoiceStrategyContext.getTaskStatistics().medRunTime &&
message.runTime != null
) {
workerTasksUsage.runTimeHistory.push(message.runTime)
workerTasksUsage: TasksUsage,
message: MessageValue<Response>
): void {
- if (this.workerChoiceStrategyContext.getRequiredStatistics().waitTime) {
+ if (this.workerChoiceStrategyContext.getTaskStatistics().waitTime) {
workerTasksUsage.waitTime += message.waitTime ?? 0
if (
- this.workerChoiceStrategyContext.getRequiredStatistics().avgWaitTime &&
+ this.workerChoiceStrategyContext.getTaskStatistics().avgWaitTime &&
workerTasksUsage.ran !== 0
) {
workerTasksUsage.avgWaitTime =
workerTasksUsage.waitTime / workerTasksUsage.ran
}
if (
- this.workerChoiceStrategyContext.getRequiredStatistics().medWaitTime &&
+ this.workerChoiceStrategyContext.getTaskStatistics().medWaitTime &&
message.waitTime != null
) {
workerTasksUsage.waitTimeHistory.push(message.waitTime)
workerTasksUsage: TasksUsage,
message: MessageValue<Response>
): void {
- if (this.workerChoiceStrategyContext.getRequiredStatistics().elu) {
+ if (this.workerChoiceStrategyContext.getTaskStatistics().elu) {
if (workerTasksUsage.elu != null && message.elu != null) {
- // TODO: cumulative or delta?
workerTasksUsage.elu = {
idle: workerTasksUsage.elu.idle + message.elu.idle,
active: workerTasksUsage.elu.active + message.elu.active,
this.pushWorkerNode(worker)
+ this.setWorkerStatistics(worker)
+
this.afterWorkerSetup(worker)
return worker
this.flushTasksQueue(workerNodeKey)
}
}
+
+ private setWorkerStatistics (worker: Worker): void {
+ this.sendToWorker(worker, {
+ statistics: {
+ runTime: this.workerChoiceStrategyContext.getTaskStatistics().runTime,
+ waitTime: this.workerChoiceStrategyContext.getTaskStatistics().waitTime,
+ elu: this.workerChoiceStrategyContext.getTaskStatistics().elu
+ }
+ })
+ }
}
import type { IWorker } from '../worker'
import type {
IWorkerChoiceStrategy,
- RequiredStatistics,
+ TaskStatistics,
WorkerChoiceStrategyOptions
} from './selection-strategies-types'
*/
private toggleFindLastFreeWorkerNodeKey: boolean = false
/** @inheritDoc */
- public readonly requiredStatistics: RequiredStatistics = {
+ public readonly taskStatistics: TaskStatistics = {
runTime: false,
avgRunTime: false,
medRunTime: false,
this.choose = this.choose.bind(this)
}
- protected setRequiredStatistics (opts: WorkerChoiceStrategyOptions): void {
- if (this.requiredStatistics.avgRunTime && opts.medRunTime === true) {
- this.requiredStatistics.avgRunTime = false
- this.requiredStatistics.medRunTime = opts.medRunTime as boolean
+ protected setTaskStatistics (opts: WorkerChoiceStrategyOptions): void {
+ if (this.taskStatistics.avgRunTime && opts.medRunTime === true) {
+ this.taskStatistics.avgRunTime = false
+ this.taskStatistics.medRunTime = opts.medRunTime as boolean
}
- if (this.requiredStatistics.medRunTime && opts.medRunTime === false) {
- this.requiredStatistics.avgRunTime = true
- this.requiredStatistics.medRunTime = opts.medRunTime as boolean
+ if (this.taskStatistics.medRunTime && opts.medRunTime === false) {
+ this.taskStatistics.avgRunTime = true
+ this.taskStatistics.medRunTime = opts.medRunTime as boolean
}
- if (this.requiredStatistics.avgWaitTime && opts.medWaitTime === true) {
- this.requiredStatistics.avgWaitTime = false
- this.requiredStatistics.medWaitTime = opts.medWaitTime as boolean
+ if (this.taskStatistics.avgWaitTime && opts.medWaitTime === true) {
+ this.taskStatistics.avgWaitTime = false
+ this.taskStatistics.medWaitTime = opts.medWaitTime as boolean
}
- if (this.requiredStatistics.medWaitTime && opts.medWaitTime === false) {
- this.requiredStatistics.avgWaitTime = true
- this.requiredStatistics.medWaitTime = opts.medWaitTime as boolean
+ if (this.taskStatistics.medWaitTime && opts.medWaitTime === false) {
+ this.taskStatistics.avgWaitTime = true
+ this.taskStatistics.medWaitTime = opts.medWaitTime as boolean
}
}
/** @inheritDoc */
public setOptions (opts: WorkerChoiceStrategyOptions): void {
opts = opts ?? DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
- this.setRequiredStatistics(opts)
+ this.setTaskStatistics(opts)
this.opts = opts
}
* @returns The worker task runtime.
*/
protected getWorkerTaskRunTime (workerNodeKey: number): number {
- return this.requiredStatistics.medRunTime
+ return this.taskStatistics.medRunTime
? this.pool.workerNodes[workerNodeKey].tasksUsage.medRunTime
: this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime
}
* @returns The worker task wait time.
*/
protected getWorkerWaitTime (workerNodeKey: number): number {
- return this.requiredStatistics.medWaitTime
+ return this.taskStatistics.medWaitTime
? this.pool.workerNodes[workerNodeKey].tasksUsage.medWaitTime
: this.pool.workerNodes[workerNodeKey].tasksUsage.avgWaitTime
}
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
- RequiredStatistics,
+ TaskStatistics,
WorkerChoiceStrategyOptions
} from './selection-strategies-types'
extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
implements IWorkerChoiceStrategy {
/** @inheritDoc */
- public readonly requiredStatistics: RequiredStatistics = {
+ public readonly taskStatistics: TaskStatistics = {
runTime: true,
avgRunTime: true,
medRunTime: false,
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setRequiredStatistics(this.opts)
+ this.setTaskStatistics(this.opts)
}
/** @inheritDoc */
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setRequiredStatistics(this.opts)
+ this.setTaskStatistics(this.opts)
this.defaultWorkerWeight = this.computeDefaultWorkerWeight()
this.roundWeights = this.getRoundWeights()
}
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
- RequiredStatistics,
+ TaskStatistics,
WorkerChoiceStrategyOptions
} from './selection-strategies-types'
extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
implements IWorkerChoiceStrategy {
/** @inheritDoc */
- public readonly requiredStatistics: RequiredStatistics = {
+ public readonly taskStatistics: TaskStatistics = {
runTime: true,
avgRunTime: false,
medRunTime: false,
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setRequiredStatistics(this.opts)
+ this.setTaskStatistics(this.opts)
}
/** @inheritDoc */
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setRequiredStatistics(this.opts)
+ this.setTaskStatistics(this.opts)
}
/** @inheritDoc */
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setRequiredStatistics(this.opts)
+ this.setTaskStatistics(this.opts)
}
/** @inheritDoc */
*
* @internal
*/
-export interface RequiredStatistics {
+export interface TaskStatistics {
/**
* Require tasks runtime.
*/
*/
export interface IWorkerChoiceStrategy {
/**
- * Required tasks usage statistics.
+ * Required tasks statistics.
*/
- readonly requiredStatistics: RequiredStatistics
+ readonly taskStatistics: TaskStatistics
/**
* Resets strategy internals.
*
import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
- RequiredStatistics,
+ TaskStatistics,
WorkerChoiceStrategyOptions
} from './selection-strategies-types'
extends AbstractWorkerChoiceStrategy<Worker, Data, Response>
implements IWorkerChoiceStrategy {
/** @inheritDoc */
- public readonly requiredStatistics: RequiredStatistics = {
+ public readonly taskStatistics: TaskStatistics = {
runTime: true,
avgRunTime: true,
medRunTime: false,
opts: WorkerChoiceStrategyOptions = DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS
) {
super(pool, opts)
- this.setRequiredStatistics(this.opts)
+ this.setTaskStatistics(this.opts)
this.defaultWorkerWeight = this.computeDefaultWorkerWeight()
}
import { RoundRobinWorkerChoiceStrategy } from './round-robin-worker-choice-strategy'
import type {
IWorkerChoiceStrategy,
- RequiredStatistics,
+ TaskStatistics,
WorkerChoiceStrategy,
WorkerChoiceStrategyOptions
} from './selection-strategies-types'
}
/**
- * Gets the worker choice strategy in the context required statistics.
+ * Gets the worker choice strategy task statistics in the context.
*
- * @returns The required statistics.
+ * @returns The task statistics.
*/
- public getRequiredStatistics (): RequiredStatistics {
+ public getTaskStatistics (): TaskStatistics {
return (
this.workerChoiceStrategies.get(
this.workerChoiceStrategy
) as IWorkerChoiceStrategy
- ).requiredStatistics
+ ).taskStatistics
}
/**
*/
readonly data?: Data
/**
- * Submission timestamp.
+ * Timestamp.
*/
- readonly submissionTimestamp?: number
+ readonly timestamp?: number
/**
* Message UUID.
*/
*/
export type Draft<T> = { -readonly [P in keyof T]?: T[P] }
+/**
+ * Performance statistics computation.
+ */
+export interface WorkerStatistics {
+ runTime: boolean
+ waitTime: boolean
+ elu: boolean
+}
+
/**
* Message object that is passed between main worker and worker.
*
* Reference to main worker.
*/
readonly parent?: MainWorker
+ /**
+ * Whether to compute the given statistics or not.
+ */
+ readonly statistics?: WorkerStatistics
}
-/**
- * Worker synchronous function that can be executed.
- *
- * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
- * @typeParam Response - Type of execution response. This can only be serializable data.
- */
-export type WorkerSyncFunction<Data = unknown, Response = unknown> = (
- data?: Data
-) => Response
-
-/**
- * Worker asynchronous function that can be executed.
- * This function must return a promise.
- *
- * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
- * @typeParam Response - Type of execution response. This can only be serializable data.
- */
-export type WorkerAsyncFunction<Data = unknown, Response = unknown> = (
- data?: Data
-) => Promise<Response>
-
-/**
- * Worker function that can be executed.
- * This function can be synchronous or asynchronous.
- *
- * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
- * @typeParam Response - Type of execution response. This can only be serializable data.
- */
-export type WorkerFunction<Data = unknown, Response = unknown> =
- | WorkerSyncFunction<Data, Response>
- | WorkerAsyncFunction<Data, Response>
-
-/**
- * Worker functions that can be executed.
- * This object can contain synchronous or asynchronous functions.
- * The key is the name of the function.
- * The value is the function itself.
- *
- * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
- * @typeParam Response - Type of execution response. This can only be serializable data.
- */
-export type TaskFunctions<Data = unknown, Response = unknown> = Record<
-string,
-WorkerFunction<Data, Response>
->
-
/**
* An object holding the execution response promise resolve/reject callbacks.
*
import type { Worker } from 'node:cluster'
import type { MessagePort } from 'node:worker_threads'
import { type EventLoopUtilization, performance } from 'node:perf_hooks'
-import type {
- MessageValue,
- TaskFunctions,
- WorkerAsyncFunction,
- WorkerFunction,
- WorkerSyncFunction
-} from '../utility-types'
+import type { MessageValue, WorkerStatistics } from '../utility-types'
import { EMPTY_FUNCTION, isPlainObject } from '../utils'
import {
type KillBehavior,
KillBehaviors,
type WorkerOptions
} from './worker-options'
+import type {
+ TaskFunctions,
+ WorkerAsyncFunction,
+ WorkerFunction,
+ WorkerSyncFunction
+} from './worker-functions'
const DEFAULT_FUNCTION_NAME = 'default'
const DEFAULT_MAX_INACTIVE_TIME = 60000
const DEFAULT_KILL_BEHAVIOR: KillBehavior = KillBehaviors.SOFT
+/**
+ * Task performance.
+ */
interface TaskPerformance {
timestamp: number
- waitTime: number
+ waitTime?: number
runTime?: number
- elu: EventLoopUtilization
+ elu?: EventLoopUtilization
}
/**
* Timestamp of the last task processed by this worker.
*/
protected lastTaskTimestamp!: number
+ /**
+ * Performance statistics computation.
+ */
+ protected statistics!: WorkerStatistics
/**
* Handler id of the `aliveInterval` worker alive check.
*/
)
this.checkAlive.bind(this)()
}
-
this.mainWorker?.on('message', this.messageListener.bind(this))
}
// Kill message received
this.aliveInterval != null && clearInterval(this.aliveInterval)
this.emitDestroy()
+ } else if (message.statistics != null) {
+ // Statistics message received
+ this.statistics = message.statistics
}
}
}
private beforeTaskRunHook (message: MessageValue<Data>): TaskPerformance {
- // TODO: conditional accounting
const timestamp = performance.now()
return {
timestamp,
- waitTime: timestamp - (message.submissionTimestamp ?? 0),
- elu: performance.eventLoopUtilization()
+ ...(this.statistics.waitTime && {
+ waitTime: timestamp - (message.timestamp ?? timestamp)
+ }),
+ ...(this.statistics.elu && { elu: performance.eventLoopUtilization() })
}
}
private afterTaskRunHook (taskPerformance: TaskPerformance): TaskPerformance {
return {
...taskPerformance,
- ...{
- runTime: performance.now() - taskPerformance.timestamp,
+ ...(this.statistics.runTime && {
+ runTime: performance.now() - taskPerformance.timestamp
+ }),
+ ...(this.statistics.elu && {
elu: performance.eventLoopUtilization(taskPerformance.elu)
- }
+ })
}
}
}
import cluster, { type Worker } from 'node:cluster'
-import type {
- MessageValue,
- TaskFunctions,
- WorkerFunction
-} from '../utility-types'
+import type { MessageValue } from '../utility-types'
import { AbstractWorker } from './abstract-worker'
import type { WorkerOptions } from './worker-options'
+import type { TaskFunctions, WorkerFunction } from './worker-functions'
/**
* A cluster worker used by a poolifier `ClusterPool`.
import { type MessagePort, isMainThread, parentPort } from 'node:worker_threads'
-import type {
- MessageValue,
- TaskFunctions,
- WorkerFunction
-} from '../utility-types'
+import type { MessageValue } from '../utility-types'
import { AbstractWorker } from './abstract-worker'
import type { WorkerOptions } from './worker-options'
+import type { TaskFunctions, WorkerFunction } from './worker-functions'
/**
* A thread worker used by a poolifier `ThreadPool`.
--- /dev/null
+/**
+ * Worker synchronous function that can be executed.
+ *
+ * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
+ * @typeParam Response - Type of execution response. This can only be serializable data.
+ */
+export type WorkerSyncFunction<Data = unknown, Response = unknown> = (
+ data?: Data
+) => Response
+
+/**
+ * Worker asynchronous function that can be executed.
+ * This function must return a promise.
+ *
+ * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
+ * @typeParam Response - Type of execution response. This can only be serializable data.
+ */
+export type WorkerAsyncFunction<Data = unknown, Response = unknown> = (
+ data?: Data
+) => Promise<Response>
+
+/**
+ * Worker function that can be executed.
+ * This function can be synchronous or asynchronous.
+ *
+ * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
+ * @typeParam Response - Type of execution response. This can only be serializable data.
+ */
+export type WorkerFunction<Data = unknown, Response = unknown> =
+ | WorkerSyncFunction<Data, Response>
+ | WorkerAsyncFunction<Data, Response>
+
+/**
+ * Worker functions that can be executed.
+ * This object can contain synchronous or asynchronous functions.
+ * The key is the name of the function.
+ * The value is the function itself.
+ *
+ * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
+ * @typeParam Response - Type of execution response. This can only be serializable data.
+ */
+export type TaskFunctions<Data = unknown, Response = unknown> = Record<
+string,
+WorkerFunction<Data, Response>
+>
medWaitTime: false
})
}
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: true,
avgRunTime: true,
medRunTime: false,
.workerChoiceStrategies) {
expect(workerChoiceStrategy.opts).toStrictEqual({ medRunTime: true })
}
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: true,
avgRunTime: false,
medRunTime: true,
.workerChoiceStrategies) {
expect(workerChoiceStrategy.opts).toStrictEqual({ medRunTime: false })
}
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: true,
avgRunTime: true,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: false,
avgRunTime: false,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: false,
avgRunTime: false,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: false,
avgRunTime: false,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: false,
avgRunTime: false,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: true,
avgRunTime: false,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: true,
avgRunTime: false,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: true,
avgRunTime: true,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: true,
avgRunTime: true,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: true,
avgRunTime: true,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: true,
avgRunTime: true,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: false,
avgRunTime: false,
medRunTime: false,
'./tests/worker-files/thread/testWorker.js',
{ workerChoiceStrategy }
)
- expect(
- pool.workerChoiceStrategyContext.getRequiredStatistics()
- ).toStrictEqual({
+ expect(pool.workerChoiceStrategyContext.getTaskStatistics()).toStrictEqual({
runTime: false,
avgRunTime: false,
medRunTime: false,
medRunTime: true
}
)
- expect(workerChoiceStrategyContext.getRequiredStatistics().avgRunTime).toBe(
+ expect(workerChoiceStrategyContext.getTaskStatistics().avgRunTime).toBe(
false
)
- expect(workerChoiceStrategyContext.getRequiredStatistics().medRunTime).toBe(
+ expect(workerChoiceStrategyContext.getTaskStatistics().medRunTime).toBe(
true
)
workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
medRunTime: true
}
)
- expect(workerChoiceStrategyContext.getRequiredStatistics().avgRunTime).toBe(
+ expect(workerChoiceStrategyContext.getTaskStatistics().avgRunTime).toBe(
false
)
- expect(workerChoiceStrategyContext.getRequiredStatistics().medRunTime).toBe(
+ expect(workerChoiceStrategyContext.getTaskStatistics().medRunTime).toBe(
true
)
const fsWorkerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
medRunTime: true
}
)
- expect(workerChoiceStrategyContext.getRequiredStatistics().avgRunTime).toBe(
+ expect(workerChoiceStrategyContext.getTaskStatistics().avgRunTime).toBe(
false
)
- expect(workerChoiceStrategyContext.getRequiredStatistics().medRunTime).toBe(
+ expect(workerChoiceStrategyContext.getTaskStatistics().medRunTime).toBe(
true
)
workerChoiceStrategyContext = new WorkerChoiceStrategyContext(
medRunTime: true
}
)
- expect(workerChoiceStrategyContext.getRequiredStatistics().avgRunTime).toBe(
+ expect(workerChoiceStrategyContext.getTaskStatistics().avgRunTime).toBe(
false
)
- expect(workerChoiceStrategyContext.getRequiredStatistics().medRunTime).toBe(
+ expect(workerChoiceStrategyContext.getTaskStatistics().medRunTime).toBe(
true
)
})