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