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