X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fversus-external-pools%2Ffixed-worker-threads-pool.js;fp=benchmarks%2Fversus-external-pools%2Ffixed-worker-threads-pool.js;h=ed7e2ae1db49a3712ab2276e7002d1095d106b2f;hb=79e7d3680bb510d4c5419701de6638fb19816c2c;hp=0000000000000000000000000000000000000000;hpb=4bb8728ce2731889275c35541cbbb74d96760a40;p=poolifier.git diff --git a/benchmarks/versus-external-pools/fixed-worker-threads-pool.js b/benchmarks/versus-external-pools/fixed-worker-threads-pool.js new file mode 100644 index 00000000..ed7e2ae1 --- /dev/null +++ b/benchmarks/versus-external-pools/fixed-worker-threads-pool.js @@ -0,0 +1,29 @@ +// IMPORT LIBRARIES +const Pool = require('worker-threads-pool') +// FINISH IMPORT LIBRARIES +const size = Number(process.env.POOL_SIZE) +const iterations = Number(process.env.NUM_ITERATIONS) +const data = { + test: 'MYBENCH', + taskType: process.env['TASK_TYPE'] +} + +const pool = new Pool({ max: size }) + +async function run () { + const promises = [] + for (let i = 0; i < iterations; i++) { + promises.push( + pool.acquire( + './workers/worker-threads-pool/function-to-bench-worker.js', + { + workerData: data + } + ) + ) + } + await Promise.all(promises) + process.exit() +} + +run()