Removed max tasks (#225)
[poolifier.git] / benchmarks / internal / cluster / dynamic.js
CommitLineData
be0676b3 1const { DynamicClusterPool } = require('../../../lib/index')
325f50bc
S
2
3const size = 30
4
5const dynamicPool = new DynamicClusterPool(
6 size / 2,
7 size * 3,
1927ee67 8 './benchmarks/internal/cluster/worker.js'
325f50bc
S
9)
10
11async function dynamicClusterTest (
12 { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } }
13) {
14 return new Promise((resolve, reject) => {
15 let executions = 0
16 for (let i = 0; i <= tasks; i++) {
17 dynamicPool
18 .execute(workerData)
19 .then(res => {
20 executions++
21 if (executions === tasks) {
22 return resolve('FINISH')
23 }
24 return null
25 })
26 .catch(err => console.error(err))
27 }
28 })
29}
30
31module.exports = { dynamicClusterTest }