refactor: convert benchmarks code to ESM
[poolifier.git] / benchmarks / versus-external-pools / dynamic-piscina.mjs
similarity index 85%
rename from benchmarks/versus-external-pools/dynamic-piscina.js
rename to benchmarks/versus-external-pools/dynamic-piscina.mjs
index 6b835d0ee37239460ca81c00564292da647cb224..6fcc6793869f38d236c9f956962ed871376fccb6 100644 (file)
@@ -1,5 +1,5 @@
 // IMPORT LIBRARIES
-const Piscina = require('piscina')
+import Piscina from 'piscina'
 // FINISH IMPORT LIBRARIES
 const size = parseInt(process.env.POOL_SIZE)
 const iterations = parseInt(process.env.NUM_ITERATIONS)
@@ -10,7 +10,7 @@ const data = {
 }
 
 const piscina = new Piscina({
-  filename: './workers/piscina/function-to-bench-worker.js',
+  filename: './workers/piscina/function-to-bench-worker.mjs',
   minThreads: size,
   maxThreads: size * 3,
   idleTimeout: 60000 // this is the same as poolifier default
@@ -26,4 +26,4 @@ async function run () {
   process.exit()
 }
 
-run()
+await run()