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