X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fversus-external-pools%2Ffixed-tinypool.mjs;h=307ac3b53de2ef01355dd2c3ab80b800da95c40d;hb=f4d1dbd1592e24d7a09f35013c3e0f0762240254;hp=0875e3f4d513b1a737a908da80bf44d5d46548e9;hpb=c9577f2d11abedb767d52bc4fbbb7531089800a6;p=poolifier.git diff --git a/benchmarks/versus-external-pools/fixed-tinypool.mjs b/benchmarks/versus-external-pools/fixed-tinypool.mjs index 0875e3f4..307ac3b5 100644 --- a/benchmarks/versus-external-pools/fixed-tinypool.mjs +++ b/benchmarks/versus-external-pools/fixed-tinypool.mjs @@ -1,6 +1,6 @@ -// IMPORT LIBRARIES import Tinypool from 'tinypool' -// FINISH IMPORT LIBRARIES +import { executeAsyncFn } from './utils.mjs' + const size = parseInt(process.env.POOL_SIZE) const iterations = parseInt(process.env.NUM_ITERATIONS) const data = { @@ -10,20 +10,20 @@ const data = { } const tinypool = new Tinypool({ - filename: './workers/tinypool/function-to-bench-worker.js', + filename: './workers/tinypool/function-to-bench-worker.mjs', minThreads: size, maxThreads: size, idleTimeout: 60000 // this is the same as poolifier default }) async function run () { - const promises = [] + const promises = new Set() for (let i = 0; i < iterations; i++) { - promises.push(tinypool.run(data)) + promises.add(tinypool.run(data)) } await Promise.all(promises) // eslint-disable-next-line n/no-process-exit process.exit() } -run() +await executeAsyncFn(run)