README.md: Small refinements
[poolifier.git] / benchmarks / 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/cluster/worker.js',
9 {
10 maxTasks: 10000
11 }
12 )
13
14 async function dynamicClusterTest (
15 { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } }
16 ) {
17 return new Promise((resolve, reject) => {
18 let executions = 0
19 for (let i = 0; i <= tasks; i++) {
20 dynamicPool
21 .execute(workerData)
22 .then(res => {
23 executions++
24 if (executions === tasks) {
25 return resolve('FINISH')
26 }
27 return null
28 })
29 .catch(err => console.error(err))
30 }
31 })
32 }
33
34 module.exports = { dynamicClusterTest }