X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Finternal%2Fcluster%2Fdynamic.js;h=105bbdaa9d77eef540cfa361e6d794095b400363;hb=b4e757784e2b9ffe2c22b65b21e8bf665abd9f56;hp=6838e07a9cad0e882f62c68d8d890f5ec4a003ea;hpb=74750c7f0a8b83b3a579f4d7fc96070ca540b234;p=poolifier.git diff --git a/benchmarks/internal/cluster/dynamic.js b/benchmarks/internal/cluster/dynamic.js index 6838e07a..105bbdaa 100644 --- a/benchmarks/internal/cluster/dynamic.js +++ b/benchmarks/internal/cluster/dynamic.js @@ -2,9 +2,10 @@ const { DynamicClusterPool, WorkerChoiceStrategies } = require('../../../lib/index') -const { runPoolifierTest } = require('../benchmark-utils') +const { runPoolifierTest } = require('../../benchmarks-utils') const size = 30 +const numberOfTasks = 1 const dynamicPool = new DynamicClusterPool( size / 2, @@ -19,19 +20,47 @@ const dynamicPoolLessRecentlyUsed = new DynamicClusterPool( { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } ) +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 dynamicClusterTestLessRecentlyUsed ( - { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } } + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData }) } +async function dynamicClusterTestWeightedRoundRobin ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(dynamicPoolWeightedRoundRobin, { tasks, workerData }) +} + +async function dynamicClusterTestFairShare ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(dynamicPoolFairShare, { tasks, workerData }) +} + module.exports = { dynamicClusterTest, - dynamicClusterTestLessRecentlyUsed + dynamicClusterTestLessRecentlyUsed, + dynamicClusterTestWeightedRoundRobin, + dynamicClusterTestFairShare }