refactor: add PoolEvents/PoolEvent types
[poolifier.git] / benchmarks / internal / cluster / fixed.js
... / ...
CommitLineData
1const {
2 FixedClusterPool,
3 WorkerChoiceStrategies
4} = require('../../../lib/index')
5const { runPoolifierTest } = require('../../benchmarks-utils')
6
7const size = 30
8const numberOfTasks = 1
9
10const fixedPool = new FixedClusterPool(
11 size,
12 './benchmarks/internal/cluster/worker.js'
13)
14
15const fixedPoolLessUsed = new FixedClusterPool(
16 size,
17 './benchmarks/internal/cluster/worker.js',
18 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED }
19)
20
21const fixedPoolLessBusy = new FixedClusterPool(
22 size,
23 './benchmarks/internal/cluster/worker.js',
24 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_BUSY }
25)
26
27const fixedPoolWeightedRoundRobin = new FixedClusterPool(
28 size,
29 './benchmarks/internal/cluster/worker.js',
30 { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
31)
32
33const fixedPoolFairShare = new FixedClusterPool(
34 size,
35 './benchmarks/internal/cluster/worker.js',
36 { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
37)
38
39async function fixedClusterTest (
40 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
41) {
42 return runPoolifierTest(fixedPool, { tasks, workerData })
43}
44
45async function fixedClusterTestLessUsed (
46 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
47) {
48 return runPoolifierTest(fixedPoolLessUsed, { tasks, workerData })
49}
50
51async function fixedClusterTestLessBusy (
52 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
53) {
54 return runPoolifierTest(fixedPoolLessBusy, { tasks, workerData })
55}
56
57async function fixedClusterTestWeightedRoundRobin (
58 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
59) {
60 return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData })
61}
62
63async function fixedClusterTestFairShare (
64 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
65) {
66 return runPoolifierTest(fixedPoolFairShare, { tasks, workerData })
67}
68
69module.exports = {
70 fixedClusterTest,
71 fixedClusterTestLessUsed,
72 fixedClusterTestLessBusy,
73 fixedClusterTestWeightedRoundRobin,
74 fixedClusterTestFairShare
75}