chore: generate documentation
[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
869b1a45
JB
15const fixedPoolTasksQueue = new FixedClusterPool(
16 size,
17 './benchmarks/internal/cluster/worker.js',
18 { enableTasksQueue: true }
19)
20
168c526f 21const fixedPoolLessUsed = new FixedClusterPool(
292ad316
JB
22 size,
23 './benchmarks/internal/cluster/worker.js',
737c6d97 24 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED }
292ad316
JB
25)
26
d4abc60a
JB
27const fixedPoolLessBusy = new FixedClusterPool(
28 size,
29 './benchmarks/internal/cluster/worker.js',
30 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_BUSY }
31)
32
2d401b2d
JB
33const fixedPoolWeightedRoundRobin = new FixedClusterPool(
34 size,
35 './benchmarks/internal/cluster/worker.js',
36 { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
37)
38
23ff945a
JB
39const fixedPoolFairShare = new FixedClusterPool(
40 size,
41 './benchmarks/internal/cluster/worker.js',
42 { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
43)
44
325f50bc 45async function fixedClusterTest (
e843b904 46 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
325f50bc 47) {
74750c7f 48 return runPoolifierTest(fixedPool, { tasks, workerData })
325f50bc
S
49}
50
869b1a45
JB
51async function fixedClusterTasksQueueTest (
52 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
53) {
54 return runPoolifierTest(fixedPoolTasksQueue, { tasks, workerData })
55}
56
168c526f 57async function fixedClusterTestLessUsed (
e843b904 58 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
292ad316 59) {
168c526f 60 return runPoolifierTest(fixedPoolLessUsed, { tasks, workerData })
292ad316
JB
61}
62
d4abc60a
JB
63async function fixedClusterTestLessBusy (
64 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
65) {
66 return runPoolifierTest(fixedPoolLessBusy, { tasks, workerData })
67}
68
2d401b2d
JB
69async function fixedClusterTestWeightedRoundRobin (
70 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
71) {
72 return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData })
73}
74
23ff945a
JB
75async function fixedClusterTestFairShare (
76 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
77) {
78 return runPoolifierTest(fixedPoolFairShare, { tasks, workerData })
79}
80
81module.exports = {
82 fixedClusterTest,
869b1a45 83 fixedClusterTasksQueueTest,
168c526f 84 fixedClusterTestLessUsed,
d4abc60a 85 fixedClusterTestLessBusy,
2d401b2d
JB
86 fixedClusterTestWeightedRoundRobin,
87 fixedClusterTestFairShare
23ff945a 88}