Fix strategy handling in pool options (#259)
[poolifier.git] / benchmarks / internal / thread / fixed.js
1 const {
2 FixedThreadPool,
3 WorkerChoiceStrategies
4 } = require('../../../lib/index')
5 const { runPoolifierTest } = require('../benchmark-utils')
6
7 const size = 30
8 const numberOfTasks = 1
9
10 const fixedPool = new FixedThreadPool(
11 size,
12 './benchmarks/internal/thread/worker.js'
13 )
14
15 const fixedPoolLessRecentlyUsed = new FixedThreadPool(
16 size,
17 './benchmarks/internal/thread/worker.js',
18 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
19 )
20
21 async function fixedThreadTest (
22 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
23 ) {
24 return runPoolifierTest(fixedPool, { tasks, workerData })
25 }
26
27 async function fixedThreadTestLessRecentlyUsed (
28 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
29 ) {
30 return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData })
31 }
32
33 module.exports = { fixedThreadTest, fixedThreadTestLessRecentlyUsed }