Commit | Line | Data |
---|---|---|
be0676b3 APA |
1 | // IMPORT LIBRARIES |
2 | const Piscina = require('piscina') | |
3 | // FINISH IMPORT LIBRARIES | |
6bd72cd0 JB |
4 | const size = parseInt(process.env.POOL_SIZE) |
5 | const iterations = parseInt(process.env.NUM_ITERATIONS) | |
be0676b3 | 6 | const data = { |
9f7e7a99 | 7 | test: 'MYBENCH', |
7a6a0a96 | 8 | taskType: process.env.TASK_TYPE, |
6bd72cd0 | 9 | taskSize: parseInt(process.env.TASK_SIZE) |
be0676b3 APA |
10 | } |
11 | ||
12 | const piscina = new Piscina({ | |
9f7e7a99 | 13 | filename: './workers/piscina/function-to-bench-worker.js', |
79e7d368 | 14 | minThreads: size, |
be0676b3 | 15 | maxThreads: size * 3, |
978aad6f | 16 | idleTimeout: 60000 // this is the same as poolifier default |
be0676b3 APA |
17 | }) |
18 | ||
19 | async function run () { | |
20 | const promises = [] | |
21 | for (let i = 0; i < iterations; i++) { | |
73cda448 | 22 | promises.push(piscina.run(data)) |
be0676b3 APA |
23 | } |
24 | await Promise.all(promises) | |
2f8c5b5c | 25 | // eslint-disable-next-line n/no-process-exit |
be0676b3 APA |
26 | process.exit() |
27 | } | |
28 | ||
29 | run() |