Commit | Line | Data |
---|---|---|
8fca9288 | 1 | import Piscina from 'piscina' |
35704ec7 | 2 | import { executeAsyncFn } from './utils.mjs' |
479ba9f6 | 3 | |
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({ | |
8fca9288 | 13 | filename: './workers/piscina/function-to-bench-worker.mjs', |
02749105 JB |
14 | minThreads: Math.floor(size / 2), |
15 | maxThreads: size, | |
978aad6f | 16 | idleTimeout: 60000 // this is the same as poolifier default |
be0676b3 APA |
17 | }) |
18 | ||
19 | async function run () { | |
1655b92e | 20 | const promises = new Set() |
be0676b3 | 21 | for (let i = 0; i < iterations; i++) { |
1655b92e | 22 | promises.add(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 | ||
479ba9f6 | 29 | await executeAsyncFn(run) |