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, |
978aad6f | 15 | idleTimeout: 60000 // this is the same as poolifier default |
be0676b3 APA |
16 | }) |
17 | ||
18 | async function run () { | |
19 | const promises = [] | |
20 | for (let i = 0; i < iterations; i++) { | |
73cda448 | 21 | promises.push(piscina.run(data)) |
be0676b3 APA |
22 | } |
23 | await Promise.all(promises) | |
2f8c5b5c | 24 | // eslint-disable-next-line n/no-process-exit |
be0676b3 APA |
25 | process.exit() |
26 | } | |
27 | ||
28 | run() |