Fix strategy handling in pool options (#259)
[poolifier.git] / benchmarks / internal / thread / fixed.js
index 966fc0e19ce42bae944a3ea8a4f2484e64870dc1..617aa7e5950952c241c2c98a091e2cf8965553b6 100644 (file)
@@ -1,17 +1,33 @@
-const { FixedThreadPool } = require('../../../lib/index')
+const {
+  FixedThreadPool,
+  WorkerChoiceStrategies
+} = require('../../../lib/index')
 const { runPoolifierTest } = require('../benchmark-utils')
 
 const size = 30
+const numberOfTasks = 1
 
 const fixedPool = new FixedThreadPool(
   size,
   './benchmarks/internal/thread/worker.js'
 )
 
+const fixedPoolLessRecentlyUsed = new FixedThreadPool(
+  size,
+  './benchmarks/internal/thread/worker.js',
+  { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
+)
+
 async function fixedThreadTest (
-  { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } }
+  { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
 ) {
   return runPoolifierTest(fixedPool, { tasks, workerData })
 }
 
-module.exports = { fixedThreadTest }
+async function fixedThreadTestLessRecentlyUsed (
+  { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
+) {
+  return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData })
+}
+
+module.exports = { fixedThreadTest, fixedThreadTestLessRecentlyUsed }