feat: add less busy worker choice strategy
[poolifier.git] / benchmarks / internal / cluster / fixed.js
CommitLineData
292ad316
JB
1const {
2 FixedClusterPool,
3 WorkerChoiceStrategies
4} = require('../../../lib/index')
d1a9aa41 5const { runPoolifierTest } = require('../../benchmarks-utils')
325f50bc
S
6
7const size = 30
e843b904 8const numberOfTasks = 1
325f50bc 9
be0676b3
APA
10const fixedPool = new FixedClusterPool(
11 size,
1927ee67 12 './benchmarks/internal/cluster/worker.js'
be0676b3 13)
325f50bc 14
168c526f 15const fixedPoolLessUsed = new FixedClusterPool(
292ad316
JB
16 size,
17 './benchmarks/internal/cluster/worker.js',
737c6d97 18 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED }
292ad316
JB
19)
20
2d401b2d
JB
21const fixedPoolWeightedRoundRobin = new FixedClusterPool(
22 size,
23 './benchmarks/internal/cluster/worker.js',
24 { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
25)
26
23ff945a
JB
27const fixedPoolFairShare = new FixedClusterPool(
28 size,
29 './benchmarks/internal/cluster/worker.js',
30 { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
31)
32
325f50bc 33async function fixedClusterTest (
e843b904 34 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
325f50bc 35) {
74750c7f 36 return runPoolifierTest(fixedPool, { tasks, workerData })
325f50bc
S
37}
38
168c526f 39async function fixedClusterTestLessUsed (
e843b904 40 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
292ad316 41) {
168c526f 42 return runPoolifierTest(fixedPoolLessUsed, { tasks, workerData })
292ad316
JB
43}
44
2d401b2d
JB
45async function fixedClusterTestWeightedRoundRobin (
46 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
47) {
48 return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData })
49}
50
23ff945a
JB
51async function fixedClusterTestFairShare (
52 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
53) {
54 return runPoolifierTest(fixedPoolFairShare, { tasks, workerData })
55}
56
57module.exports = {
58 fixedClusterTest,
168c526f 59 fixedClusterTestLessUsed,
2d401b2d
JB
60 fixedClusterTestWeightedRoundRobin,
61 fixedClusterTestFairShare
23ff945a 62}