Merge dependabot/npm_and_yarn/examples/typescript/websocket-server-pool/ws-worker_thr...
[poolifier.git] / benchmarks / versus-external-pools / static-node-worker-threads-pool.mjs
index 3632216b5daeed0771077f873bbf9bca5e69f177..db14b180e6633461542a96a1df9f6b270e32bf80 100644 (file)
@@ -1,9 +1,7 @@
-// IMPORT LIBRARIES
 import { StaticPool } 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,7 +10,7 @@ const data = {
   taskSize: parseInt(process.env.TASK_SIZE)
 }
 
-const pool = new StaticPool({
+const staticPool = new StaticPool({
   size,
   task: functionToBench
 })
@@ -20,11 +18,11 @@ const pool = new StaticPool({
 async function run () {
   const promises = new Set()
   for (let i = 0; i < iterations; i++) {
-    promises.add(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)