X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=benchmarks%2Fversus-external-pools%2Fdynamic-node-worker-threads-pool.mjs;h=c4be1ee1c6d1a0ca312d1597c1d8e4a48406d5fd;hb=79b9b76a5b4ee41d536a37c5e52a50c4236b31a9;hp=debe85132cf190fb262f2bac3d4f4032772540bb;hpb=bea2d6e33a81c97cfb0cc003befd149eddcd4708;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 debe8513..c4be1ee1 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 './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,15 +10,16 @@ const data = { taskSize: parseInt(process.env.TASK_SIZE) } -const pool = new DynamicPool(size) +const dynamicPool = new DynamicPool(size) async function run () { - const promises = [] + const promises = new Set() for (let i = 0; i < iterations; i++) { - promises.push( - pool.exec({ + promises.add( + dynamicPool.exec({ task: functionToBench, - param: data + param: data, + timeout: 60000 // this is the same as poolifier default }) ) } @@ -29,4 +28,4 @@ async function run () { process.exit() } -await run() +await executeAsyncFn(run)