README.md: Small refinements
[poolifier.git] / benchmarks / cluster / fixed.js
CommitLineData
325f50bc
S
1const { FixedClusterPool } = require('../../lib/index')
2
3const size = 30
4
5const fixedPool = new FixedClusterPool(size, './benchmarks/cluster/worker.js', {
6 maxTasks: 10000
7})
8
9async 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
31module.exports = { fixedClusterTest }