chore: v2.4.8
[poolifier.git] / benchmarks / internal / cluster / dynamic.js
index 7ad9dd282d5e27a7afcdcd10e9a0d4c860e4e75c..475ba9d79b953fdfabf075010d94ddb979fe93eb 100644 (file)
@@ -2,9 +2,10 @@ const {
   DynamicClusterPool,
   WorkerChoiceStrategies
 } = require('../../../lib/index')
-const { runTest } = require('../benchmark-utils')
+const { runPoolifierTest } = require('../../benchmarks-utils')
 
 const size = 30
+const numberOfTasks = 1
 
 const dynamicPool = new DynamicClusterPool(
   size / 2,
@@ -12,26 +13,68 @@ 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(
+  size / 2,
+  size * 3,
+  './benchmarks/internal/cluster/worker.js',
+  { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
 )
 
 async function dynamicClusterTest (
-  { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } }
+  { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
+) {
+  return runPoolifierTest(dynamicPool, { tasks, workerData })
+}
+
+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 runTest(dynamicPool, { tasks, workerData })
+  return runPoolifierTest(dynamicPoolWeightedRoundRobin, { tasks, workerData })
 }
 
-async function dynamicClusterTestLessRecentlyUsed (
-  { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } }
+async function dynamicClusterTestFairShare (
+  { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
 ) {
-  return runTest(dynamicPoolLessRecentlyUsed, { tasks, workerData })
+  return runPoolifierTest(dynamicPoolFairShare, { tasks, workerData })
 }
 
 module.exports = {
   dynamicClusterTest,
-  dynamicClusterTestLessRecentlyUsed
+  dynamicClusterTestLessUsed,
+  dynamicClusterTestLessBusy,
+  dynamicClusterTestWeightedRoundRobin,
+  dynamicClusterTestFairShare
 }