build: refine ignored files
[poolifier.git] / benchmarks / versus-external-pools / threadjs.js
index a70692bb6e3b3a39eb452063ce9cca716b5d8673..ee9178e92b7954663efd9855f069476423d6bb06 100644 (file)
@@ -1,31 +1,34 @@
 // IMPORT LIBRARIES
-const { spawn, Thread, Worker } = require('threads')
+const { spawn, Worker } = require('threads')
 // FINISH IMPORT LIBRARIES
-const size = process.env.POOL_SIZE
-const iterations = process.env.NUM_ITERATIONS
+const size = parseInt(process.env.POOL_SIZE)
+const iterations = parseInt(process.env.NUM_ITERATIONS)
 const data = {
   test: 'MYBENCH',
-  taskType: process.env['TASK_TYPE']
+  taskType: process.env.TASK_TYPE,
+  taskSize: parseInt(process.env.TASK_SIZE)
 }
 
 // Threads.js is not really a pool so we need to write few additional code
 const workers = []
 async function poolify () {
-  for (let i = 0; i < size ; i++ ){
-    const worker = await spawn(new Worker("./workers/threadjs/function-to-bench-worker.js"))
+  for (let i = 0; i < size; i++) {
+    const worker = await spawn(
+      new Worker('./workers/threadjs/function-to-bench-worker.js')
+    )
     workers.push(worker)
   }
 }
 
-
 async function run () {
   await poolify()
   const promises = []
   for (let i = 0; i < iterations; i++) {
-    const worker = workers[(i % size)]
+    const worker = workers[i % size]
     promises.push(worker.exposedFunction(data))
   }
   await Promise.all(promises)
+  // eslint-disable-next-line n/no-process-exit
   process.exit()
 }