Switch to push-protected GH action for typedoc usage
[poolifier.git] / benchmarks / internal / cluster / dynamic.js
... / ...
CommitLineData
1const {
2 DynamicClusterPool,
3 WorkerChoiceStrategies
4} = require('../../../lib/index')
5const { runPoolifierTest } = require('../../benchmarks-utils')
6
7const size = 30
8const numberOfTasks = 1
9
10const dynamicPool = new DynamicClusterPool(
11 size / 2,
12 size * 3,
13 './benchmarks/internal/cluster/worker.js'
14)
15
16const dynamicPoolLessRecentlyUsed = new DynamicClusterPool(
17 size / 2,
18 size * 3,
19 './benchmarks/internal/cluster/worker.js',
20 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
21)
22
23const dynamicPoolWeightedRoundRobin = new DynamicClusterPool(
24 size / 2,
25 size * 3,
26 './benchmarks/internal/cluster/worker.js',
27 { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
28)
29
30const dynamicPoolFairShare = new DynamicClusterPool(
31 size / 2,
32 size * 3,
33 './benchmarks/internal/cluster/worker.js',
34 { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
35)
36
37async function dynamicClusterTest (
38 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
39) {
40 return runPoolifierTest(dynamicPool, { tasks, workerData })
41}
42
43async function dynamicClusterTestLessRecentlyUsed (
44 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
45) {
46 return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData })
47}
48
49async function dynamicClusterTestWeightedRoundRobin (
50 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
51) {
52 return runPoolifierTest(dynamicPoolWeightedRoundRobin, { tasks, workerData })
53}
54
55async function dynamicClusterTestFairShare (
56 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
57) {
58 return runPoolifierTest(dynamicPoolFairShare, { tasks, workerData })
59}
60
61module.exports = {
62 dynamicClusterTest,
63 dynamicClusterTestLessRecentlyUsed,
64 dynamicClusterTestWeightedRoundRobin,
65 dynamicClusterTestFairShare
66}