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