Commit | Line | Data |
---|---|---|
292ad316 JB |
1 | const { |
2 | FixedClusterPool, | |
3 | WorkerChoiceStrategies | |
4 | } = require('../../../lib/index') | |
74750c7f | 5 | const { runPoolifierTest } = require('../benchmark-utils') |
325f50bc S |
6 | |
7 | const size = 30 | |
e843b904 | 8 | const numberOfTasks = 1 |
325f50bc | 9 | |
be0676b3 APA |
10 | const fixedPool = new FixedClusterPool( |
11 | size, | |
1927ee67 | 12 | './benchmarks/internal/cluster/worker.js' |
be0676b3 | 13 | ) |
325f50bc | 14 | |
292ad316 JB |
15 | const fixedPoolLessRecentlyUsed = new FixedClusterPool( |
16 | size, | |
17 | './benchmarks/internal/cluster/worker.js', | |
18 | { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } | |
19 | ) | |
20 | ||
23ff945a JB |
21 | const fixedPoolFairShare = new FixedClusterPool( |
22 | size, | |
23 | './benchmarks/internal/cluster/worker.js', | |
24 | { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE } | |
25 | ) | |
26 | ||
325f50bc | 27 | async function fixedClusterTest ( |
e843b904 | 28 | { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } |
325f50bc | 29 | ) { |
74750c7f | 30 | return runPoolifierTest(fixedPool, { tasks, workerData }) |
325f50bc S |
31 | } |
32 | ||
292ad316 | 33 | async function fixedClusterTestLessRecentlyUsed ( |
e843b904 | 34 | { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } |
292ad316 JB |
35 | ) { |
36 | return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData }) | |
37 | } | |
38 | ||
23ff945a JB |
39 | async function fixedClusterTestFairShare ( |
40 | { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } | |
41 | ) { | |
42 | return runPoolifierTest(fixedPoolFairShare, { tasks, workerData }) | |
43 | } | |
44 | ||
45 | module.exports = { | |
46 | fixedClusterTest, | |
47 | fixedClusterTestFairShare, | |
48 | fixedClusterTestLessRecentlyUsed | |
49 | } |