Add WRR worker choice strategy to benchmark
[poolifier.git] / benchmarks / internal / cluster / fixed.js
... / ...
CommitLineData
1const {
2 FixedClusterPool,
3 WorkerChoiceStrategies
4} = require('../../../lib/index')
5const { runPoolifierTest } = require('../benchmark-utils')
6
7const size = 30
8const numberOfTasks = 1
9
10const fixedPool = new FixedClusterPool(
11 size,
12 './benchmarks/internal/cluster/worker.js'
13)
14
15const fixedPoolLessRecentlyUsed = new FixedClusterPool(
16 size,
17 './benchmarks/internal/cluster/worker.js',
18 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
19)
20
21const fixedPoolWeightedRoundRobin = new FixedClusterPool(
22 size,
23 './benchmarks/internal/cluster/worker.js',
24 { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
25)
26
27const fixedPoolFairShare = new FixedClusterPool(
28 size,
29 './benchmarks/internal/cluster/worker.js',
30 { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
31)
32
33async function fixedClusterTest (
34 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
35) {
36 return runPoolifierTest(fixedPool, { tasks, workerData })
37}
38
39async function fixedClusterTestLessRecentlyUsed (
40 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
41) {
42 return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData })
43}
44
45async function fixedClusterTestWeightedRoundRobin (
46 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
47) {
48 return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData })
49}
50
51async function fixedClusterTestFairShare (
52 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
53) {
54 return runPoolifierTest(fixedPoolFairShare, { tasks, workerData })
55}
56
57module.exports = {
58 fixedClusterTest,
59 fixedClusterTestLessRecentlyUsed,
60 fixedClusterTestWeightedRoundRobin,
61 fixedClusterTestFairShare
62}