Stricter tests expectations
[poolifier.git] / benchmarks / internal / cluster / dynamic.js
... / ...
CommitLineData
1const {
2 DynamicClusterPool,
3 WorkerChoiceStrategies
4} = require('../../../lib/index')
5const { runPoolifierTest } = require('../benchmark-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 dynamicPoolFairShare = new DynamicClusterPool(
24 size / 2,
25 size * 3,
26 './benchmarks/internal/cluster/worker.js',
27 { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
28)
29
30async function dynamicClusterTest (
31 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
32) {
33 return runPoolifierTest(dynamicPool, { tasks, workerData })
34}
35
36async function dynamicClusterTestLessRecentlyUsed (
37 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
38) {
39 return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData })
40}
41
42async function dynamicClusterTestFairShare (
43 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
44) {
45 return runPoolifierTest(dynamicPoolFairShare, { tasks, workerData })
46}
47
48module.exports = {
49 dynamicClusterTest,
50 dynamicClusterTestFairShare,
51 dynamicClusterTestLessRecentlyUsed
52}