function buildPool (workerType, poolType, poolSize, poolOptions) {
switch (poolType) {
- case PoolTypes.FIXED:
+ case PoolTypes.fixed:
switch (workerType) {
- case WorkerTypes.THREAD:
+ case WorkerTypes.thread:
return new FixedThreadPool(
poolSize,
'./benchmarks/internal/thread-worker.js',
poolOptions
)
- case WorkerTypes.CLUSTER:
+ case WorkerTypes.cluster:
return new FixedClusterPool(
poolSize,
'./benchmarks/internal/cluster-worker.js',
)
}
break
- case PoolTypes.DYNAMIC:
+ case PoolTypes.dynamic:
switch (workerType) {
- case WorkerTypes.THREAD:
+ case WorkerTypes.thread:
return new DynamicThreadPool(
poolSize / 2,
poolSize * 3,
'./benchmarks/internal/thread-worker.js',
poolOptions
)
- case WorkerTypes.CLUSTER:
+ case WorkerTypes.cluster:
return new DynamicClusterPool(
poolSize / 2,
poolSize * 3,
}
const fixedThreadPoolRoundRobin = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.FIXED,
+ WorkerTypes.thread,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyRoundRobinPoolOption
)
const fixedThreadPoolRoundRobinTasksQueue = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.FIXED,
+ WorkerTypes.thread,
+ PoolTypes.fixed,
poolSize,
{ ...workerChoiceStrategyRoundRobinPoolOption, ...tasksQueuePoolOption }
)
const fixedThreadPoolLeastUsed = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.FIXED,
+ WorkerTypes.thread,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyLeastUsedPoolOption
)
const fixedThreadPoolLeastBusy = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.FIXED,
+ WorkerTypes.thread,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyLeastBusyPoolOption
)
const fixedThreadPoolWeightedRoundRobin = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.FIXED,
+ WorkerTypes.thread,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyWeightedRoundRobinPoolOption
)
const fixedThreadPoolFairShare = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.FIXED,
+ WorkerTypes.thread,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyFairSharePoolOption
)
const fixedThreadPoolFairShareTasksQueue = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.FIXED,
+ WorkerTypes.thread,
+ PoolTypes.fixed,
poolSize,
{ ...workerChoiceStrategyFairSharePoolOption, ...tasksQueuePoolOption }
)
const dynamicThreadPoolRoundRobin = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.DYNAMIC,
+ WorkerTypes.thread,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyRoundRobinPoolOption
)
const dynamicThreadPoolLeastUsed = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.DYNAMIC,
+ WorkerTypes.thread,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyLeastUsedPoolOption
)
const dynamicThreadPoolLeastBusy = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.DYNAMIC,
+ WorkerTypes.thread,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyLeastBusyPoolOption
)
const dynamicThreadPoolWeightedRoundRobin = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.DYNAMIC,
+ WorkerTypes.thread,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyWeightedRoundRobinPoolOption
)
const dynamicThreadPoolFairShare = buildPool(
- WorkerTypes.THREAD,
- PoolTypes.DYNAMIC,
+ WorkerTypes.thread,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyFairSharePoolOption
)
const fixedClusterPoolRoundRobin = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.FIXED,
+ WorkerTypes.cluster,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyRoundRobinPoolOption
)
const fixedClusterPoolRoundRobinTasksQueue = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.FIXED,
+ WorkerTypes.cluster,
+ PoolTypes.fixed,
poolSize,
{ ...workerChoiceStrategyRoundRobinPoolOption, ...tasksQueuePoolOption }
)
const fixedClusterPoolLeastUsed = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.FIXED,
+ WorkerTypes.cluster,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyLeastUsedPoolOption
)
const fixedClusterPoolLeastBusy = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.FIXED,
+ WorkerTypes.cluster,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyLeastBusyPoolOption
)
const fixedClusterPoolWeightedRoundRobin = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.FIXED,
+ WorkerTypes.cluster,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyWeightedRoundRobinPoolOption
)
const fixedClusterPoolFairShare = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.FIXED,
+ WorkerTypes.cluster,
+ PoolTypes.fixed,
poolSize,
workerChoiceStrategyFairSharePoolOption
)
const fixedClusterPoolFairShareTaskQueue = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.FIXED,
+ WorkerTypes.cluster,
+ PoolTypes.fixed,
poolSize,
{ ...workerChoiceStrategyFairSharePoolOption, ...tasksQueuePoolOption }
)
const dynamicClusterPoolRoundRobin = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.DYNAMIC,
+ WorkerTypes.cluster,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyRoundRobinPoolOption
)
const dynamicClusterPoolLeastUsed = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.DYNAMIC,
+ WorkerTypes.cluster,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyLeastUsedPoolOption
)
const dynamicClusterPoolLeastBusy = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.DYNAMIC,
+ WorkerTypes.cluster,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyLeastBusyPoolOption
)
const dynamicClusterPoolWeightedRoundRobin = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.DYNAMIC,
+ WorkerTypes.cluster,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyWeightedRoundRobinPoolOption
)
const dynamicClusterPoolFairShare = buildPool(
- WorkerTypes.CLUSTER,
- PoolTypes.DYNAMIC,
+ WorkerTypes.cluster,
+ PoolTypes.dynamic,
poolSize,
workerChoiceStrategyFairSharePoolOption
)
"eslint-define-config": "^1.20.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
- "eslint-plugin-jsdoc": "^46.2.0",
+ "eslint-plugin-jsdoc": "^46.2.1",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-spellcheck": "^0.0.20",
specifier: ^2.27.5
version: 2.27.5(@typescript-eslint/parser@5.59.8)(eslint-import-resolver-typescript@3.5.5)(eslint@8.42.0)
eslint-plugin-jsdoc:
- specifier: ^46.2.0
- version: 46.2.0(eslint@8.42.0)
+ specifier: ^46.2.1
+ version: 46.2.1(eslint@8.42.0)
eslint-plugin-n:
specifier: ^16.0.0
version: 16.0.0(eslint@8.42.0)
- supports-color
dev: true
- /eslint-plugin-jsdoc@46.2.0(eslint@8.42.0):
- resolution: {integrity: sha512-Lo2Bs39UPtcvLGfBrI/RF+8mOPcYaHdj++YTfDrqrWHND2trGQBDKxCVcEyYACrQxyMYgpfqHkyxE0S184hOGg==}
+ /eslint-plugin-jsdoc@46.2.1(eslint@8.42.0):
+ resolution: {integrity: sha512-rsv3EE2FGDpYTSnIzDHpf9SsB7ccTmCl8dMcJzpBAOLiJ1maIMYMOfPDqT1IB+Y21muD894xhO6BTrOIvY5mfg==}
engines: {node: '>=16'}
peerDependencies:
eslint: ^7.0.0 || ^8.0.0
} = require('../lib/worker/worker-options')
describe('Utils test suite', () => {
- it('Verify median computation', () => {
+ it('Verify median() computation', () => {
expect(median([])).toBe(0)
expect(median([0.08])).toBe(0.08)
expect(median([0.25, 4.75, 3.05, 6.04, 1.01, 2.02, 5.03])).toBe(3.05)