Commit | Line | Data |
---|---|---|
144f78e0 JB |
1 | // IMPORT LIBRARIES |
2 | const workerpool = require('workerpool') | |
3 | // FINISH IMPORT LIBRARIES | |
79e7d368 JB |
4 | const size = Number(process.env.POOL_SIZE) |
5 | const iterations = Number(process.env.NUM_ITERATIONS) | |
7a6a0a96 | 6 | const dataArray = ['MYBENCH', process.env.TASK_TYPE, process.env.TASK_SIZE] |
144f78e0 JB |
7 | |
8 | const workerPool = workerpool.pool( | |
9 | './workers/workerpool/function-to-bench-worker.js', | |
10 | { | |
79e7d368 | 11 | minWorkers: size, |
144f78e0 JB |
12 | maxWorkers: size * 3, |
13 | workerType: 'thread' | |
14 | } | |
15 | ) | |
16 | ||
17 | async function run () { | |
18 | const promises = [] | |
19 | for (let i = 0; i < iterations; i++) { | |
20 | promises.push(workerPool.exec('functionToBench', dataArray)) | |
21 | } | |
22 | await Promise.all(promises) | |
7a6a0a96 | 23 | // eslint-disable-next-line no-process-exit |
144f78e0 JB |
24 | process.exit() |
25 | } | |
26 | ||
27 | run() |