refactor: untangle utils purpose
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 13 Jan 2024 13:40:22 +0000 (14:40 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 13 Jan 2024 13:40:22 +0000 (14:40 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
12 files changed:
src/pools/selection-strategies/abstract-worker-choice-strategy.ts
src/pools/selection-strategies/fair-share-worker-choice-strategy.ts
src/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.ts
src/pools/selection-strategies/least-busy-worker-choice-strategy.ts
src/pools/selection-strategies/least-elu-worker-choice-strategy.ts
src/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.ts
src/pools/selection-strategies/worker-choice-strategy-context.ts
src/pools/utils.ts
src/pools/worker-node.ts
src/utils.ts
tests/pools/utils.test.mjs
tests/utils.test.mjs

index f244374291da55b9173129b6384b00f49d952e65..ff1d4b0847e3bd53be4c06bd3d252523f3ff545e 100644 (file)
@@ -1,8 +1,8 @@
+import type { IPool } from '../pool.js'
 import {
   DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
   buildWorkerChoiceStrategyOptions
-} from '../../utils.js'
-import type { IPool } from '../pool.js'
+} from '../utils.js'
 import type { IWorker } from '../worker.js'
 import type {
   IWorkerChoiceStrategy,
index f87465582b2070ee748bcd650806f29b8aeebeb3..ee617d36253cac9c6e8b0970725b139c1ad5b1a5 100644 (file)
@@ -1,5 +1,5 @@
-import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../../utils.js'
 import type { IPool } from '../pool.js'
+import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../utils.js'
 import type { IWorker } from '../worker.js'
 import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy.js'
 import {
index 681870cbf1ad18b9fb10dfb539769c3abdd50777..6bbcc5f5b965e1fa3c0d05b018437b4f2e796708 100644 (file)
@@ -1,6 +1,6 @@
 import type { IWorker } from '../worker.js'
 import type { IPool } from '../pool.js'
-import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../../utils.js'
+import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../utils.js'
 import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy.js'
 import type {
   IWorkerChoiceStrategy,
index 5ef438f6084a1d3fb0d26326870bf351d5a5972d..8db32ac7f1421330e36d9bfb81bddf53392a666c 100644 (file)
@@ -1,5 +1,5 @@
-import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../../utils.js'
 import type { IPool } from '../pool.js'
+import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../utils.js'
 import type { IWorker } from '../worker.js'
 import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy.js'
 import type {
index c3fe32d144176d88e848a8923fa1eb4b63126f88..9cb28bacfc2bcbcc91605c6a4914d46fd21f7da0 100644 (file)
@@ -1,5 +1,5 @@
-import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../../utils.js'
 import type { IPool } from '../pool.js'
+import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../utils.js'
 import type { IWorker } from '../worker.js'
 import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy.js'
 import type {
index 434b1f86f0ff6f1f8ace1ce722a2ee983bd4f6b3..c86682cbf0405cc9e308ac3374ad998f09b2da12 100644 (file)
@@ -1,6 +1,6 @@
 import type { IWorker } from '../worker.js'
 import type { IPool } from '../pool.js'
-import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../../utils.js'
+import { DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS } from '../utils.js'
 import { AbstractWorkerChoiceStrategy } from './abstract-worker-choice-strategy.js'
 import type {
   IWorkerChoiceStrategy,
index d8d6f9c4b638fef5305228a22576f84aad7370a8..fc940a2fbb0f7d85ec450cc35beb60cab75cd141 100644 (file)
@@ -1,6 +1,6 @@
 import type { IPool } from '../pool.js'
 import type { IWorker } from '../worker.js'
-import { getWorkerChoiceStrategyRetries } from '../../utils.js'
+import { getWorkerChoiceStrategyRetries } from '../utils.js'
 import { FairShareWorkerChoiceStrategy } from './fair-share-worker-choice-strategy.js'
 import { InterleavedWeightedRoundRobinWorkerChoiceStrategy } from './interleaved-weighted-round-robin-worker-choice-strategy.js'
 import { LeastBusyWorkerChoiceStrategy } from './least-busy-worker-choice-strategy.js'
index a97f3e6e121d1cb3e366aa277a4bcbd43b6d6429..ff2709826076459a8ef4ee417221b333b3ca70e3 100644 (file)
@@ -1,15 +1,22 @@
 import { existsSync } from 'node:fs'
-import cluster from 'node:cluster'
-import { SHARE_ENV, Worker, type WorkerOptions } from 'node:worker_threads'
+import cluster, { Worker as ClusterWorker } from 'node:cluster'
+import {
+  SHARE_ENV,
+  Worker as ThreadWorker,
+  type WorkerOptions
+} from 'node:worker_threads'
 import { env } from 'node:process'
+import { randomInt } from 'node:crypto'
+import { cpus } from 'node:os'
 import { average, isPlainObject, max, median, min } from '../utils.js'
 import type { MessageValue, Task } from '../utility-types.js'
 import {
   type MeasurementStatisticsRequirements,
   WorkerChoiceStrategies,
-  type WorkerChoiceStrategy
+  type WorkerChoiceStrategy,
+  type WorkerChoiceStrategyOptions
 } from './selection-strategies/selection-strategies-types.js'
-import type { TasksQueueOptions } from './pool.js'
+import type { IPool, TasksQueueOptions } from './pool.js'
 import {
   type IWorker,
   type IWorkerNode,
@@ -21,6 +28,16 @@ import {
 } from './worker.js'
 import type { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context.js'
 
+/**
+ * Default measurement statistics requirements.
+ */
+export const DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS: MeasurementStatisticsRequirements =
+  {
+    aggregate: false,
+    average: false,
+    median: false
+  }
+
 export const getDefaultTasksQueueOptions = (
   poolMaxSize: number
 ): Required<TasksQueueOptions> => {
@@ -33,6 +50,75 @@ export const getDefaultTasksQueueOptions = (
   }
 }
 
+export const getWorkerChoiceStrategyRetries = <
+  Worker extends IWorker,
+  Data,
+  Response
+>(
+    pool: IPool<Worker, Data, Response>,
+    opts?: WorkerChoiceStrategyOptions
+  ): number => {
+  return (
+    pool.info.maxSize +
+    Object.keys(opts?.weights ?? getDefaultWeights(pool.info.maxSize)).length
+  )
+}
+
+export const buildWorkerChoiceStrategyOptions = <
+  Worker extends IWorker,
+  Data,
+  Response
+>(
+    pool: IPool<Worker, Data, Response>,
+    opts?: WorkerChoiceStrategyOptions
+  ): WorkerChoiceStrategyOptions => {
+  opts = clone(opts ?? {})
+  opts.weights = opts.weights ?? getDefaultWeights(pool.info.maxSize)
+  return {
+    ...{
+      runTime: { median: false },
+      waitTime: { median: false },
+      elu: { median: false }
+    },
+    ...opts
+  }
+}
+
+const clone = <T>(object: T): T => {
+  return structuredClone<T>(object)
+}
+
+const getDefaultWeights = (
+  poolMaxSize: number,
+  defaultWorkerWeight?: number
+): Record<number, number> => {
+  defaultWorkerWeight = defaultWorkerWeight ?? getDefaultWorkerWeight()
+  const weights: Record<number, number> = {}
+  for (let workerNodeKey = 0; workerNodeKey < poolMaxSize; workerNodeKey++) {
+    weights[workerNodeKey] = defaultWorkerWeight
+  }
+  return weights
+}
+
+const getDefaultWorkerWeight = (): number => {
+  const cpuSpeed = randomInt(500, 2500)
+  let cpusCycleTimeWeight = 0
+  for (const cpu of cpus()) {
+    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+    if (cpu.speed == null || cpu.speed === 0) {
+      cpu.speed =
+        // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+        cpus().find(cpu => cpu.speed != null && cpu.speed !== 0)?.speed ??
+        cpuSpeed
+    }
+    // CPU estimated cycle time
+    const numberOfDigits = cpu.speed.toString().length - 1
+    const cpuCycleTime = 1 / (cpu.speed / Math.pow(10, numberOfDigits))
+    cpusCycleTimeWeight += cpuCycleTime * Math.pow(10, numberOfDigits)
+  }
+  return Math.round(cpusCycleTimeWeight / cpus().length)
+}
+
 export const checkFilePath = (filePath: string | undefined): void => {
   if (filePath == null) {
     throw new TypeError('The worker file path must be specified')
@@ -316,7 +402,7 @@ export const createWorker = <Worker extends IWorker>(
 ): Worker => {
   switch (type) {
     case WorkerTypes.thread:
-      return new Worker(filePath, {
+      return new ThreadWorker(filePath, {
         env: SHARE_ENV,
         ...opts.workerOptions
       }) as unknown as Worker
@@ -328,6 +414,36 @@ export const createWorker = <Worker extends IWorker>(
   }
 }
 
+/**
+ * Returns the worker type of the given worker.
+ *
+ * @param worker - The worker to get the type of.
+ * @returns The worker type of the given worker.
+ * @internal
+ */
+export const getWorkerType = (worker: IWorker): WorkerType | undefined => {
+  if (worker instanceof ThreadWorker) {
+    return WorkerTypes.thread
+  } else if (worker instanceof ClusterWorker) {
+    return WorkerTypes.cluster
+  }
+}
+
+/**
+ * Returns the worker id of the given worker.
+ *
+ * @param worker - The worker to get the id of.
+ * @returns The worker id of the given worker.
+ * @internal
+ */
+export const getWorkerId = (worker: IWorker): number | undefined => {
+  if (worker instanceof ThreadWorker) {
+    return worker.threadId
+  } else if (worker instanceof ClusterWorker) {
+    return worker.id
+  }
+}
+
 export const waitWorkerNodeEvents = async <
   Worker extends IWorker,
   Data = unknown
index a9f9ca5f71fac8adf9655a105d55307e78884d5a..308215176edb515851c2349ba550d3cc50e2611b 100644 (file)
@@ -2,7 +2,7 @@ import { MessageChannel } from 'node:worker_threads'
 import { EventEmitter } from 'node:events'
 import { CircularArray } from '../circular-array.js'
 import type { Task } from '../utility-types.js'
-import { DEFAULT_TASK_NAME, getWorkerId, getWorkerType } from '../utils.js'
+import { DEFAULT_TASK_NAME } from '../utils.js'
 import { Deque } from '../deque.js'
 import {
   type EventHandler,
@@ -15,7 +15,12 @@ import {
   WorkerTypes,
   type WorkerUsage
 } from './worker.js'
-import { checkWorkerNodeArguments, createWorker } from './utils.js'
+import {
+  checkWorkerNodeArguments,
+  createWorker,
+  getWorkerId,
+  getWorkerType
+} from './utils.js'
 
 /**
  * Worker node.
index b38cf948e833ef41ccc7d183db0498a8e4257ed0..d74cfbfd3768592134fce5df367bb15ab299d5d4 100644 (file)
@@ -1,15 +1,6 @@
 import * as os from 'node:os'
-import { getRandomValues, randomInt } from 'node:crypto'
-import { Worker as ClusterWorker } from 'node:cluster'
-import { Worker as ThreadWorker } from 'node:worker_threads'
-import { cpus } from 'node:os'
-import type {
-  MeasurementStatisticsRequirements,
-  WorkerChoiceStrategyOptions
-} from './pools/selection-strategies/selection-strategies-types.js'
+import { getRandomValues } from 'node:crypto'
 import type { KillBehavior } from './worker/worker-options.js'
-import { type IWorker, type WorkerType, WorkerTypes } from './pools/worker.js'
-import type { IPool } from './pools/pool.js'
 
 /**
  * Default task name.
@@ -23,16 +14,6 @@ export const EMPTY_FUNCTION: () => void = Object.freeze(() => {
   /* Intentionally empty */
 })
 
-/**
- * Default measurement statistics requirements.
- */
-export const DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS: MeasurementStatisticsRequirements =
-  {
-    aggregate: false,
-    average: false,
-    median: false
-  }
-
 /**
  * Returns safe host OS optimized estimate of the default amount of parallelism a pool should use.
  * Always returns a value greater than zero.
@@ -52,36 +33,6 @@ export const availableParallelism = (): number => {
   return availableParallelism
 }
 
-/**
- * Returns the worker type of the given worker.
- *
- * @param worker - The worker to get the type of.
- * @returns The worker type of the given worker.
- * @internal
- */
-export const getWorkerType = (worker: IWorker): WorkerType | undefined => {
-  if (worker instanceof ThreadWorker) {
-    return WorkerTypes.thread
-  } else if (worker instanceof ClusterWorker) {
-    return WorkerTypes.cluster
-  }
-}
-
-/**
- * Returns the worker id of the given worker.
- *
- * @param worker - The worker to get the id of.
- * @returns The worker id of the given worker.
- * @internal
- */
-export const getWorkerId = (worker: IWorker): number | undefined => {
-  if (worker instanceof ThreadWorker) {
-    return worker.threadId
-  } else if (worker instanceof ClusterWorker) {
-    return worker.id
-  }
-}
-
 /**
  * Sleeps for the given amount of milliseconds.
  *
@@ -122,8 +73,7 @@ export const exponentialDelay = (
 export const average = (dataSet: number[]): number => {
   if (Array.isArray(dataSet) && dataSet.length === 0) {
     return 0
-  }
-  if (Array.isArray(dataSet) && dataSet.length === 1) {
+  } else if (Array.isArray(dataSet) && dataSet.length === 1) {
     return dataSet[0]
   }
   return (
@@ -142,8 +92,7 @@ export const average = (dataSet: number[]): number => {
 export const median = (dataSet: number[]): number => {
   if (Array.isArray(dataSet) && dataSet.length === 0) {
     return 0
-  }
-  if (Array.isArray(dataSet) && dataSet.length === 1) {
+  } else if (Array.isArray(dataSet) && dataSet.length === 1) {
     return dataSet[0]
   }
   const sortedDataSet = dataSet.slice().sort((a, b) => a - b)
@@ -175,7 +124,7 @@ export const round = (num: number, scale = 2): number => {
  * @returns `true` if the given object is a plain object, `false` otherwise.
  * @internal
  */
-export const isPlainObject = (obj: unknown): boolean =>
+export const isPlainObject = (obj: unknown): obj is object =>
   typeof obj === 'object' &&
   obj !== null &&
   obj.constructor === Object &&
@@ -200,7 +149,7 @@ export const isKillBehavior = <KB extends KillBehavior>(
 /**
  * Detects whether the given value is an asynchronous function or not.
  *
- * @param fn - Any value.
+ * @param fn - Unknown value.
  * @returns `true` if `fn` was an asynchronous function, otherwise `false`.
  * @internal
  */
@@ -266,72 +215,3 @@ export const once = <T, A extends any[], R>(
     return result
   }
 }
-
-export const getWorkerChoiceStrategyRetries = <
-  Worker extends IWorker,
-  Data,
-  Response
->(
-    pool: IPool<Worker, Data, Response>,
-    opts?: WorkerChoiceStrategyOptions
-  ): number => {
-  return (
-    pool.info.maxSize +
-    Object.keys(opts?.weights ?? getDefaultWeights(pool.info.maxSize)).length
-  )
-}
-
-const clone = <T>(object: T): T => {
-  return structuredClone<T>(object)
-}
-
-export const buildWorkerChoiceStrategyOptions = <
-  Worker extends IWorker,
-  Data,
-  Response
->(
-    pool: IPool<Worker, Data, Response>,
-    opts?: WorkerChoiceStrategyOptions
-  ): WorkerChoiceStrategyOptions => {
-  opts = clone(opts ?? {})
-  opts.weights = opts.weights ?? getDefaultWeights(pool.info.maxSize)
-  return {
-    ...{
-      runTime: { median: false },
-      waitTime: { median: false },
-      elu: { median: false }
-    },
-    ...opts
-  }
-}
-
-const getDefaultWeights = (
-  poolMaxSize: number,
-  defaultWorkerWeight?: number
-): Record<number, number> => {
-  defaultWorkerWeight = defaultWorkerWeight ?? getDefaultWorkerWeight()
-  const weights: Record<number, number> = {}
-  for (let workerNodeKey = 0; workerNodeKey < poolMaxSize; workerNodeKey++) {
-    weights[workerNodeKey] = defaultWorkerWeight
-  }
-  return weights
-}
-
-const getDefaultWorkerWeight = (): number => {
-  const cpuSpeed = randomInt(500, 2500)
-  let cpusCycleTimeWeight = 0
-  for (const cpu of cpus()) {
-    // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
-    if (cpu.speed == null || cpu.speed === 0) {
-      cpu.speed =
-        // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
-        cpus().find(cpu => cpu.speed != null && cpu.speed !== 0)?.speed ??
-        cpuSpeed
-    }
-    // CPU estimated cycle time
-    const numberOfDigits = cpu.speed.toString().length - 1
-    const cpuCycleTime = 1 / (cpu.speed / Math.pow(10, numberOfDigits))
-    cpusCycleTimeWeight += cpuCycleTime * Math.pow(10, numberOfDigits)
-  }
-  return Math.round(cpusCycleTimeWeight / cpus().length)
-}
index 610b92c3ce62cba912ab9273b14d5cb2077f9884..6869bda681315aab9b088bad60677df4e8bcc510 100644 (file)
@@ -1,18 +1,35 @@
 import { Worker as ThreadWorker } from 'node:worker_threads'
-import { Worker as ClusterWorker } from 'node:cluster'
+import cluster, { Worker as ClusterWorker } from 'node:cluster'
 import { expect } from 'expect'
 import {
   CircularArray,
   DEFAULT_CIRCULAR_ARRAY_SIZE
 } from '../../lib/circular-array.cjs'
 import {
+  DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
+  buildWorkerChoiceStrategyOptions,
   createWorker,
   getDefaultTasksQueueOptions,
+  getWorkerChoiceStrategyRetries,
+  getWorkerId,
+  getWorkerType,
   updateMeasurementStatistics
 } from '../../lib/pools/utils.cjs'
-import { WorkerTypes } from '../../lib/index.cjs'
+import {
+  FixedClusterPool,
+  FixedThreadPool,
+  WorkerTypes
+} from '../../lib/index.cjs'
 
 describe('Pool utils test suite', () => {
+  it('Verify DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS values', () => {
+    expect(DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS).toStrictEqual({
+      aggregate: false,
+      average: false,
+      median: false
+    })
+  })
+
   it('Verify getDefaultTasksQueueOptions() behavior', () => {
     const poolMaxSize = 4
     expect(getDefaultTasksQueueOptions(poolMaxSize)).toStrictEqual({
@@ -24,6 +41,61 @@ describe('Pool utils test suite', () => {
     })
   })
 
+  it('Verify getWorkerChoiceStrategyRetries() behavior', async () => {
+    const numberOfThreads = 4
+    const pool = new FixedThreadPool(
+      numberOfThreads,
+      './tests/worker-files/thread/testWorker.mjs'
+    )
+    expect(getWorkerChoiceStrategyRetries(pool)).toBe(pool.info.maxSize * 2)
+    const workerChoiceStrategyOptions = {
+      runTime: { median: true },
+      waitTime: { median: true },
+      elu: { median: true },
+      weights: {
+        0: 100,
+        1: 100
+      }
+    }
+    expect(
+      getWorkerChoiceStrategyRetries(pool, workerChoiceStrategyOptions)
+    ).toBe(
+      pool.info.maxSize +
+        Object.keys(workerChoiceStrategyOptions.weights).length
+    )
+    await pool.destroy()
+  })
+
+  it('Verify buildWorkerChoiceStrategyOptions() behavior', async () => {
+    const numberOfWorkers = 4
+    const pool = new FixedClusterPool(
+      numberOfWorkers,
+      './tests/worker-files/cluster/testWorker.cjs'
+    )
+    expect(buildWorkerChoiceStrategyOptions(pool)).toStrictEqual({
+      runTime: { median: false },
+      waitTime: { median: false },
+      elu: { median: false },
+      weights: expect.objectContaining({
+        0: expect.any(Number),
+        [pool.info.maxSize - 1]: expect.any(Number)
+      })
+    })
+    const workerChoiceStrategyOptions = {
+      runTime: { median: true },
+      waitTime: { median: true },
+      elu: { median: true },
+      weights: {
+        0: 100,
+        1: 100
+      }
+    }
+    expect(
+      buildWorkerChoiceStrategyOptions(pool, workerChoiceStrategyOptions)
+    ).toStrictEqual(workerChoiceStrategyOptions)
+    await pool.destroy()
+  })
+
   it('Verify updateMeasurementStatistics() behavior', () => {
     const measurementStatistics = {
       history: new CircularArray()
@@ -127,4 +199,22 @@ describe('Pool utils test suite', () => {
       )
     ).toBeInstanceOf(ClusterWorker)
   })
+
+  it('Verify getWorkerType() behavior', () => {
+    expect(
+      getWorkerType(
+        new ThreadWorker('./tests/worker-files/thread/testWorker.mjs')
+      )
+    ).toBe(WorkerTypes.thread)
+    expect(getWorkerType(cluster.fork())).toBe(WorkerTypes.cluster)
+  })
+
+  it('Verify getWorkerId() behavior', () => {
+    const threadWorker = new ThreadWorker(
+      './tests/worker-files/thread/testWorker.mjs'
+    )
+    const clusterWorker = cluster.fork()
+    expect(getWorkerId(threadWorker)).toBe(threadWorker.threadId)
+    expect(getWorkerId(clusterWorker)).toBe(clusterWorker.id)
+  })
 })
index 5f54f6fc8ea4e0ebe7d7f6ebc27f0efb8a5ea218..1078c1fdbff63af8c6338a7c74349196fbfdd6b7 100644 (file)
@@ -1,19 +1,12 @@
-import { Worker } from 'node:worker_threads'
-import cluster from 'node:cluster'
 import os from 'node:os'
 import { randomInt } from 'node:crypto'
 import { expect } from 'expect'
 import {
-  DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS,
   DEFAULT_TASK_NAME,
   EMPTY_FUNCTION,
   availableParallelism,
   average,
-  buildWorkerChoiceStrategyOptions,
   exponentialDelay,
-  getWorkerChoiceStrategyRetries,
-  getWorkerId,
-  getWorkerType,
   isAsyncFunction,
   isKillBehavior,
   isPlainObject,
@@ -25,12 +18,7 @@ import {
   secureRandom,
   sleep
 } from '../lib/utils.cjs'
-import {
-  FixedClusterPool,
-  FixedThreadPool,
-  KillBehaviors,
-  WorkerTypes
-} from '../lib/index.cjs'
+import { KillBehaviors } from '../lib/index.cjs'
 
 describe('Utils test suite', () => {
   it('Verify DEFAULT_TASK_NAME value', () => {
@@ -41,14 +29,6 @@ describe('Utils test suite', () => {
     expect(EMPTY_FUNCTION).toStrictEqual(expect.any(Function))
   })
 
-  it('Verify DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS values', () => {
-    expect(DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS).toStrictEqual({
-      aggregate: false,
-      average: false,
-      median: false
-    })
-  })
-
   it('Verify availableParallelism() behavior', () => {
     const parallelism = availableParallelism()
     expect(typeof parallelism === 'number').toBe(true)
@@ -62,22 +42,6 @@ describe('Utils test suite', () => {
     expect(parallelism).toBe(expectedParallelism)
   })
 
-  it('Verify getWorkerType() behavior', () => {
-    expect(
-      getWorkerType(new Worker('./tests/worker-files/thread/testWorker.mjs'))
-    ).toBe(WorkerTypes.thread)
-    expect(getWorkerType(cluster.fork())).toBe(WorkerTypes.cluster)
-  })
-
-  it('Verify getWorkerId() behavior', () => {
-    const threadWorker = new Worker(
-      './tests/worker-files/thread/testWorker.mjs'
-    )
-    const clusterWorker = cluster.fork()
-    expect(getWorkerId(threadWorker)).toBe(threadWorker.threadId)
-    expect(getWorkerId(clusterWorker)).toBe(clusterWorker.id)
-  })
-
   it('Verify sleep() behavior', async () => {
     const start = performance.now()
     const sleepMs = 1000
@@ -237,61 +201,6 @@ describe('Utils test suite', () => {
     expect(max(1, 1)).toBe(1)
   })
 
-  it('Verify getWorkerChoiceStrategyRetries() behavior', async () => {
-    const numberOfThreads = 4
-    const pool = new FixedThreadPool(
-      numberOfThreads,
-      './tests/worker-files/thread/testWorker.mjs'
-    )
-    expect(getWorkerChoiceStrategyRetries(pool)).toBe(pool.info.maxSize * 2)
-    const workerChoiceStrategyOptions = {
-      runTime: { median: true },
-      waitTime: { median: true },
-      elu: { median: true },
-      weights: {
-        0: 100,
-        1: 100
-      }
-    }
-    expect(
-      getWorkerChoiceStrategyRetries(pool, workerChoiceStrategyOptions)
-    ).toBe(
-      pool.info.maxSize +
-        Object.keys(workerChoiceStrategyOptions.weights).length
-    )
-    await pool.destroy()
-  })
-
-  it('Verify buildWorkerChoiceStrategyOptions() behavior', async () => {
-    const numberOfWorkers = 4
-    const pool = new FixedClusterPool(
-      numberOfWorkers,
-      './tests/worker-files/cluster/testWorker.cjs'
-    )
-    expect(buildWorkerChoiceStrategyOptions(pool)).toStrictEqual({
-      runTime: { median: false },
-      waitTime: { median: false },
-      elu: { median: false },
-      weights: expect.objectContaining({
-        0: expect.any(Number),
-        [pool.info.maxSize - 1]: expect.any(Number)
-      })
-    })
-    const workerChoiceStrategyOptions = {
-      runTime: { median: true },
-      waitTime: { median: true },
-      elu: { median: true },
-      weights: {
-        0: 100,
-        1: 100
-      }
-    }
-    expect(
-      buildWorkerChoiceStrategyOptions(pool, workerChoiceStrategyOptions)
-    ).toStrictEqual(workerChoiceStrategyOptions)
-    await pool.destroy()
-  })
-
   // it('Verify once()', () => {
   //   let called = 0
   //   const fn = () => ++called