Removed max tasks (#225)
[poolifier.git] / benchmarks / internal / cluster / dynamic.js
1 const { DynamicClusterPool } = require('../../../lib/index')
2
3 const size = 30
4
5 const dynamicPool = new DynamicClusterPool(
6 size / 2,
7 size * 3,
8 './benchmarks/internal/cluster/worker.js'
9 )
10
11 async 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
31 module.exports = { dynamicClusterTest }