refactor: factor out code to get worker function
[poolifier.git] / benchmarks / internal / bench.js
index 4c126a00fb9d531011b71cb52e459c2aa017b695..4663d9c42bf2f27f38b78cb417acbe96bf6f2e86 100644 (file)
@@ -31,156 +31,170 @@ 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 fixedThreadPoolFairShareTasksQueue = buildPool(
+  WorkerTypes.THREAD,
+  PoolTypes.FIXED,
+  poolSize,
+  { ...workerChoiceStrategyFairSharePoolOption, ...tasksQueuePoolOption }
+)
+
 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 fixedClusterPoolFairShareTaskQueue = buildPool(
+  WorkerTypes.CLUSTER,
+  PoolTypes.FIXED,
+  poolSize,
+  { ...workerChoiceStrategyFairSharePoolOption, ...tasksQueuePoolOption }
+)
+
 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
 )
 
@@ -228,6 +242,15 @@ Benchmark.suite(
       workerData
     })
   }),
+  Benchmark.add(
+    'Fixed:ThreadPool:FairShare:{ enableTasksQueue: true }',
+    async () => {
+      await runTest(fixedThreadPoolFairShareTasksQueue, {
+        taskExecutions,
+        workerData
+      })
+    }
+  ),
   Benchmark.add('Dynamic:ThreadPool:RoundRobin', async () => {
     await runTest(dynamicThreadPoolRoundRobin, {
       taskExecutions,
@@ -297,6 +320,15 @@ Benchmark.suite(
       workerData
     })
   }),
+  Benchmark.add(
+    'Fixed:ClusterPool:FairShare:{ enableTasksQueue: true }',
+    async () => {
+      await runTest(fixedClusterPoolFairShareTaskQueue, {
+        taskExecutions,
+        workerData
+      })
+    }
+  ),
   Benchmark.add('Dynamic:ClusterPool:RoundRobin', async () => {
     await runTest(dynamicClusterPoolRoundRobin, {
       taskExecutions,