Commit | Line | Data |
---|---|---|
6c063733 | 1 | // IMPORT LIBRARIES |
8fca9288 JB |
2 | import { resolve } from 'path' |
3 | import WorkerNodes from '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( | |
8fca9288 | 14 | resolve('./workers/worker-nodes/function-to-bench-worker'), |
6c063733 JB |
15 | { |
16 | minWorkers: size, | |
17 | maxWorkers: size, | |
18 | taskTimeout: 60000 // this is the same as poolifier default | |
19 | } | |
20 | ) | |
21 | ||
22 | async function run () { | |
23 | const promises = [] | |
24 | for (let i = 0; i < iterations; i++) { | |
25 | promises.push(workerNodes.call.functionToBench(data)) | |
26 | } | |
27 | await Promise.all(promises) | |
2f8c5b5c | 28 | // eslint-disable-next-line n/no-process-exit |
6c063733 JB |
29 | process.exit() |
30 | } | |
31 | ||
8fca9288 | 32 | await run() |