feat: add less busy worker choice strategy
[poolifier.git] / benchmarks / internal / cluster / fixed.js
index 548ed9f9eb1518a697069ee8d5cd68a6a2f61830..69e4a14870013bd5f3136d8ecb25309c9d93c163 100644 (file)
@@ -2,7 +2,7 @@ const {
   FixedClusterPool,
   WorkerChoiceStrategies
 } = require('../../../lib/index')
-const { runPoolifierTest } = require('../benchmark-utils')
+const { runPoolifierTest } = require('../../benchmarks-utils')
 
 const size = 30
 const numberOfTasks = 1
@@ -12,10 +12,16 @@ const fixedPool = new FixedClusterPool(
   './benchmarks/internal/cluster/worker.js'
 )
 
-const fixedPoolLessRecentlyUsed = new FixedClusterPool(
+const fixedPoolLessUsed = new FixedClusterPool(
   size,
   './benchmarks/internal/cluster/worker.js',
-  { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
+  { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED }
+)
+
+const fixedPoolWeightedRoundRobin = new FixedClusterPool(
+  size,
+  './benchmarks/internal/cluster/worker.js',
+  { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
 )
 
 const fixedPoolFairShare = new FixedClusterPool(
@@ -30,10 +36,16 @@ async function fixedClusterTest (
   return runPoolifierTest(fixedPool, { tasks, workerData })
 }
 
-async function fixedClusterTestLessRecentlyUsed (
+async function fixedClusterTestLessUsed (
+  { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
+) {
+  return runPoolifierTest(fixedPoolLessUsed, { tasks, workerData })
+}
+
+async function fixedClusterTestWeightedRoundRobin (
   { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
 ) {
-  return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData })
+  return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData })
 }
 
 async function fixedClusterTestFairShare (
@@ -44,6 +56,7 @@ async function fixedClusterTestFairShare (
 
 module.exports = {
   fixedClusterTest,
-  fixedClusterTestFairShare,
-  fixedClusterTestLessRecentlyUsed
+  fixedClusterTestLessUsed,
+  fixedClusterTestWeightedRoundRobin,
+  fixedClusterTestFairShare
 }