X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fversus-external-pools%2Fdynamic-node-worker-threads-pool.mjs;h=08535b68e1eabc78d6c9fc2437c1244324a697e3;hb=1c25f937c2fd468cf1363b360d8f87aceaae6e9a;hp=fcb1d84c29ee43bcb5c615418d98cfe3819b84ad;hpb=1655b92eb1223501125f6cac2f83fc86fbc958ab;p=poolifier.git diff --git a/benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs b/benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs index fcb1d84c..08535b68 100644 --- a/benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs +++ b/benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs @@ -1,9 +1,7 @@ -// IMPORT LIBRARIES import { DynamicPool } from 'node-worker-threads-pool' -// FINISH IMPORT LIBRARIES -// IMPORT FUNCTION TO BENCH +import { executeAsyncFn } from '../benchmarks-utils.mjs' import functionToBench from './functions/function-to-bench.js' -// FINISH IMPORT FUNCTION TO BENCH + const size = parseInt(process.env.POOL_SIZE) const iterations = parseInt(process.env.NUM_ITERATIONS) const data = { @@ -12,13 +10,13 @@ const data = { taskSize: parseInt(process.env.TASK_SIZE) } -const pool = new DynamicPool(size) +const dynamicPool = new DynamicPool(size) async function run () { const promises = new Set() for (let i = 0; i < iterations; i++) { promises.add( - pool.exec({ + dynamicPool.exec({ task: functionToBench, param: data, timeout: 60000 // this is the same as poolifier default @@ -30,4 +28,4 @@ async function run () { process.exit() } -await run() +await executeAsyncFn(run)