Fix strategy handling in pool options (#259)
[poolifier.git] / benchmarks / internal / cluster / dynamic.js
1 const {
2 DynamicClusterPool,
3 WorkerChoiceStrategies
4 } = require('../../../lib/index')
5 const { runPoolifierTest } = require('../benchmark-utils')
6
7 const size = 30
8 const numberOfTasks = 1
9
10 const dynamicPool = new DynamicClusterPool(
11 size / 2,
12 size * 3,
13 './benchmarks/internal/cluster/worker.js'
14 )
15
16 const dynamicPoolLessRecentlyUsed = new DynamicClusterPool(
17 size / 2,
18 size * 3,
19 './benchmarks/internal/cluster/worker.js',
20 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
21 )
22
23 async function dynamicClusterTest (
24 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
25 ) {
26 return runPoolifierTest(dynamicPool, { tasks, workerData })
27 }
28
29 async function dynamicClusterTestLessRecentlyUsed (
30 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
31 ) {
32 return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData })
33 }
34
35 module.exports = {
36 dynamicClusterTest,
37 dynamicClusterTestLessRecentlyUsed
38 }