Commit | Line | Data |
---|---|---|
be0676b3 | 1 | const { FixedClusterPool } = require('../../../lib/index') |
325f50bc S |
2 | |
3 | const size = 30 | |
4 | ||
be0676b3 APA |
5 | const fixedPool = new FixedClusterPool( |
6 | size, | |
1927ee67 | 7 | './benchmarks/internal/cluster/worker.js' |
be0676b3 | 8 | ) |
325f50bc S |
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 } |