perf: remove unneeded class indirection for dynamic pool in worker
[poolifier.git] / benchmarks / benchmarks-utils.js
index 30af25c927c38edc190ae2c5538a9c22e4569788..e6abe96d5b1e065c07b709bd83c37095e9996935 100644 (file)
@@ -9,7 +9,7 @@ async function runPoolifierTest (pool, { tasks, workerData }) {
         .then(() => {
           executions++
           if (executions === tasks) {
-            return resolve('FINISH')
+            return resolve({ ok: 1 })
           }
           return null
         })
@@ -31,8 +31,11 @@ function jsonIntegerSerialization (n) {
 }
 
 function generateRandomInteger (max = Number.MAX_SAFE_INTEGER, min = 0) {
+  if (max < min || max < 0 || min < 0) {
+    throw new RangeError('Invalid interval')
+  }
   max = Math.floor(max)
-  if (min) {
+  if (min != null && min !== 0) {
     min = Math.ceil(min)
     return Math.floor(Math.random() * (max - min + 1)) + min
   }
@@ -59,9 +62,8 @@ function fibonacci (n) {
 function factorial (n) {
   if (n === 0) {
     return 1
-  } else {
-    return factorial(n - 1) * n
   }
+  return factorial(n - 1) * n
 }
 
 function executeWorkerFunction (data) {
@@ -77,13 +79,7 @@ function executeWorkerFunction (data) {
   }
 }
 
-const LIST_FORMATTER = new Intl.ListFormat('en-US', {
-  style: 'long',
-  type: 'conjunction'
-})
-
 module.exports = {
-  LIST_FORMATTER,
   WorkerFunctions,
   executeWorkerFunction,
   generateRandomInteger,