From 1f29c16f4e4eb928115b9cd0cad8d655e1580cc3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 19 Apr 2023 00:07:05 +0200 Subject: [PATCH] refactor: reorder pool builder helper arguments MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- benchmarks/benchmarks-utils.js | 4 +--- benchmarks/internal/bench.js | 44 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/benchmarks/benchmarks-utils.js b/benchmarks/benchmarks-utils.js index 64df58c8..aac4b785 100644 --- a/benchmarks/benchmarks-utils.js +++ b/benchmarks/benchmarks-utils.js @@ -56,7 +56,6 @@ function jsonIntegerSerialization (n) { /** * Intentionally inefficient implementation. - * * @param {number} n - The number of fibonacci numbers to generate. * @returns {number} - The nth fibonacci number. */ @@ -67,7 +66,6 @@ function fibonacci (n) { /** * Intentionally inefficient implementation. - * * @param {number} n - The number to calculate the factorial of. * @returns {number} - The factorial of n. */ @@ -114,7 +112,7 @@ function executeWorkerFunction (data) { } } -function buildPool (poolType, poolSize, workerType, poolOptions) { +function buildPool (workerType, poolType, poolSize, poolOptions) { switch (poolType) { case PoolTypes.FIXED: switch (workerType) { diff --git a/benchmarks/internal/bench.js b/benchmarks/internal/bench.js index 4c126a00..d615f66e 100644 --- a/benchmarks/internal/bench.js +++ b/benchmarks/internal/bench.js @@ -31,156 +31,156 @@ const workerChoiceStrategyFairSharePoolOption = { } const fixedThreadPoolRoundRobin = buildPool( + WorkerTypes.THREAD, PoolTypes.FIXED, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyRoundRobinPoolOption ) const fixedThreadPoolRoundRobinTasksQueue = buildPool( + WorkerTypes.THREAD, PoolTypes.FIXED, poolSize, - WorkerTypes.THREAD, { ...workerChoiceStrategyRoundRobinPoolOption, ...tasksQueuePoolOption } ) const fixedThreadPoolLessUsed = buildPool( + WorkerTypes.THREAD, PoolTypes.FIXED, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyLessUsedPoolOption ) const fixedThreadPoolLessBusy = buildPool( + WorkerTypes.THREAD, PoolTypes.FIXED, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyLessBusyPoolOption ) const fixedThreadPoolWeightedRoundRobin = buildPool( + WorkerTypes.THREAD, PoolTypes.FIXED, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyWeightedRoundRobinPoolOption ) const fixedThreadPoolFairShare = buildPool( + WorkerTypes.THREAD, PoolTypes.FIXED, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyFairSharePoolOption ) const dynamicThreadPoolRoundRobin = buildPool( + WorkerTypes.THREAD, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyRoundRobinPoolOption ) const dynamicThreadPoolLessUsed = buildPool( + WorkerTypes.THREAD, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyLessUsedPoolOption ) const dynamicThreadPoolLessBusy = buildPool( + WorkerTypes.THREAD, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyLessBusyPoolOption ) const dynamicThreadPoolWeightedRoundRobin = buildPool( + WorkerTypes.THREAD, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyWeightedRoundRobinPoolOption ) const dynamicThreadPoolFairShare = buildPool( + WorkerTypes.THREAD, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.THREAD, workerChoiceStrategyFairSharePoolOption ) const fixedClusterPoolRoundRobin = buildPool( + WorkerTypes.CLUSTER, PoolTypes.FIXED, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyRoundRobinPoolOption ) const fixedClusterPoolRoundRobinTasksQueue = buildPool( + WorkerTypes.CLUSTER, PoolTypes.FIXED, poolSize, - WorkerTypes.CLUSTER, { ...workerChoiceStrategyRoundRobinPoolOption, ...tasksQueuePoolOption } ) const fixedClusterPoolLessUsed = buildPool( + WorkerTypes.CLUSTER, PoolTypes.FIXED, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyLessUsedPoolOption ) const fixedClusterPoolLessBusy = buildPool( + WorkerTypes.CLUSTER, PoolTypes.FIXED, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyLessBusyPoolOption ) const fixedClusterPoolWeightedRoundRobin = buildPool( + WorkerTypes.CLUSTER, PoolTypes.FIXED, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyWeightedRoundRobinPoolOption ) const fixedClusterPoolFairShare = buildPool( + WorkerTypes.CLUSTER, PoolTypes.FIXED, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyFairSharePoolOption ) const dynamicClusterPoolRoundRobin = buildPool( + WorkerTypes.CLUSTER, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyRoundRobinPoolOption ) const dynamicClusterPoolLessUsed = buildPool( + WorkerTypes.CLUSTER, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyLessUsedPoolOption ) const dynamicClusterPoolLessBusy = buildPool( + WorkerTypes.CLUSTER, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyLessBusyPoolOption ) const dynamicClusterPoolWeightedRoundRobin = buildPool( + WorkerTypes.CLUSTER, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyWeightedRoundRobinPoolOption ) const dynamicClusterPoolFairShare = buildPool( + WorkerTypes.CLUSTER, PoolTypes.DYNAMIC, poolSize, - WorkerTypes.CLUSTER, workerChoiceStrategyFairSharePoolOption ) -- 2.34.1