docs: update benchmark versus external pools results
[poolifier.git] / benchmarks / versus-external-pools / dynamic-piscina.mjs
index a1e425f8e95f3a19c8cc5d776cb225fd11f9b200..06c71779b4396379b47ffc912a5796862af586dc 100644 (file)
@@ -1,6 +1,6 @@
-// IMPORT LIBRARIES
 import Piscina from 'piscina'
-// FINISH IMPORT LIBRARIES
+import { executeAsyncFn } from './utils.mjs'
+
 const size = parseInt(process.env.POOL_SIZE)
 const iterations = parseInt(process.env.NUM_ITERATIONS)
 const data = {
@@ -17,13 +17,13 @@ const piscina = new Piscina({
 })
 
 async function run () {
-  const promises = []
+  const promises = new Set()
   for (let i = 0; i < iterations; i++) {
-    promises.push(piscina.run(data))
+    promises.add(piscina.run(data))
   }
   await Promise.all(promises)
   // eslint-disable-next-line n/no-process-exit
   process.exit()
 }
 
-await run()
+await executeAsyncFn(run)