Commit | Line | Data |
---|---|---|
589f0f1c | 1 | 'use strict' |
6c063733 | 2 | // IMPORT LIBRARIES |
bea2d6e3 | 3 | const WorkerNodes = require('worker-nodes') |
6c063733 | 4 | // FINISH IMPORT LIBRARIES |
6bd72cd0 JB |
5 | const size = parseInt(process.env.POOL_SIZE) |
6 | const iterations = parseInt(process.env.NUM_ITERATIONS) | |
6c063733 JB |
7 | const data = { |
8 | test: 'MYBENCH', | |
7a6a0a96 | 9 | taskType: process.env.TASK_TYPE, |
6bd72cd0 | 10 | taskSize: parseInt(process.env.TASK_SIZE) |
6c063733 JB |
11 | } |
12 | ||
13 | const workerNodes = new WorkerNodes( | |
bea2d6e3 | 14 | require.resolve('./workers/worker-nodes/function-to-bench-worker'), |
6c063733 | 15 | { |
02749105 JB |
16 | minWorkers: Math.floor(size / 2), |
17 | maxWorkers: size, | |
6c063733 JB |
18 | taskTimeout: 60000 // this is the same as poolifier default |
19 | } | |
20 | ) | |
21 | ||
22 | async function run () { | |
1655b92e | 23 | const promises = new Set() |
6c063733 | 24 | for (let i = 0; i < iterations; i++) { |
1655b92e | 25 | promises.add(workerNodes.call.functionToBench(data)) |
6c063733 JB |
26 | } |
27 | await Promise.all(promises) | |
2f8c5b5c | 28 | // eslint-disable-next-line n/no-process-exit |
6c063733 JB |
29 | process.exit() |
30 | } | |
041dc05b | 31 | (async () => { |
bea2d6e3 JB |
32 | try { |
33 | await run() | |
34 | } catch (e) { | |
35 | console.error(e) | |
36 | // eslint-disable-next-line n/no-process-exit | |
37 | process.exit(1) | |
38 | } | |
39 | })() |