chore: v2.4.8
[poolifier.git] / benchmarks / internal / cluster / dynamic.js
index 581bf4acf086073ed459ea6f30b65af0249ab021..475ba9d79b953fdfabf075010d94ddb979fe93eb 100644 (file)
@@ -2,7 +2,7 @@ const {
   DynamicClusterPool,
   WorkerChoiceStrategies
 } = require('../../../lib/index')
-const { runPoolifierTest } = require('../benchmark-utils')
+const { runPoolifierTest } = require('../../benchmarks-utils')
 
 const size = 30
 const numberOfTasks = 1
@@ -13,11 +13,25 @@ const dynamicPool = new DynamicClusterPool(
   './benchmarks/internal/cluster/worker.js'
 )
 
-const dynamicPoolLessRecentlyUsed = new DynamicClusterPool(
+const dynamicPoolLessUsed = new DynamicClusterPool(
   size / 2,
   size * 3,
   './benchmarks/internal/cluster/worker.js',
-  { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
+  { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED }
+)
+
+const dynamicPoolLessBusy = new DynamicClusterPool(
+  size / 2,
+  size * 3,
+  './benchmarks/internal/cluster/worker.js',
+  { workerChoiceStrategy: WorkerChoiceStrategies.LESS_BUSY }
+)
+
+const dynamicPoolWeightedRoundRobin = new DynamicClusterPool(
+  size / 2,
+  size * 3,
+  './benchmarks/internal/cluster/worker.js',
+  { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
 )
 
 const dynamicPoolFairShare = new DynamicClusterPool(
@@ -33,10 +47,22 @@ async function dynamicClusterTest (
   return runPoolifierTest(dynamicPool, { tasks, workerData })
 }
 
-async function dynamicClusterTestLessRecentlyUsed (
+async function dynamicClusterTestLessUsed (
+  { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
+) {
+  return runPoolifierTest(dynamicPoolLessUsed, { tasks, workerData })
+}
+
+async function dynamicClusterTestLessBusy (
+  { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
+) {
+  return runPoolifierTest(dynamicPoolLessBusy, { tasks, workerData })
+}
+
+async function dynamicClusterTestWeightedRoundRobin (
   { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
 ) {
-  return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData })
+  return runPoolifierTest(dynamicPoolWeightedRoundRobin, { tasks, workerData })
 }
 
 async function dynamicClusterTestFairShare (
@@ -47,6 +73,8 @@ async function dynamicClusterTestFairShare (
 
 module.exports = {
   dynamicClusterTest,
-  dynamicClusterTestFairShare,
-  dynamicClusterTestLessRecentlyUsed
+  dynamicClusterTestLessUsed,
+  dynamicClusterTestLessBusy,
+  dynamicClusterTestWeightedRoundRobin,
+  dynamicClusterTestFairShare
 }