X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fversus-external-pools%2Fstatic-node-worker-threads-pool.mjs;h=db14b180e6633461542a96a1df9f6b270e32bf80;hb=0471eb2db716f98408e465364a18a750e89cfcc9;hp=b943be5d4a60e1531371ce5151af359cde815674;hpb=8fca928868a8f73a16d5d990dda9a4480ea28ab5;p=poolifier.git diff --git a/benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs b/benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs index b943be5d..db14b180 100644 --- a/benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs +++ b/benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs @@ -1,9 +1,7 @@ -// IMPORT LIBRARIES import { StaticPool } from 'node-worker-threads-pool' -// FINISH IMPORT LIBRARIES -// IMPORT FUNCTION TO BENCH -import functionToBench from './functions/function-to-bench.mjs' -// FINISH IMPORT FUNCTION TO BENCH +import { executeAsyncFn } from './utils.mjs' +import functionToBench from './functions/function-to-bench.js' + const size = parseInt(process.env.POOL_SIZE) const iterations = parseInt(process.env.NUM_ITERATIONS) const data = { @@ -12,19 +10,19 @@ const data = { taskSize: parseInt(process.env.TASK_SIZE) } -const pool = new StaticPool({ +const staticPool = new StaticPool({ size, task: functionToBench }) async function run () { - const promises = [] + const promises = new Set() for (let i = 0; i < iterations; i++) { - promises.push(pool.exec(data)) + promises.add(staticPool.exec(data)) } await Promise.all(promises) // eslint-disable-next-line n/no-process-exit process.exit() } -await run() +await executeAsyncFn(run)