Fix strategy handling in pool options (#259)
[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
23async function dynamicClusterTest (
24 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
25) {
26 return runPoolifierTest(dynamicPool, { tasks, workerData })
27}
28
29async function dynamicClusterTestLessRecentlyUsed (
30 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
31) {
32 return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData })
33}
34
35module.exports = {
36 dynamicClusterTest,
37 dynamicClusterTestLessRecentlyUsed
38}