Benchmarks and tests code cleanups. (#257)
[poolifier.git] / benchmarks / internal / thread / fixed.js
CommitLineData
292ad316
JB
1const {
2 FixedThreadPool,
3 WorkerChoiceStrategies
4} = require('../../../lib/index')
74750c7f 5const { runPoolifierTest } = require('../benchmark-utils')
325f50bc
S
6
7const size = 30
8
ff5e76e1
JB
9const fixedPool = new FixedThreadPool(
10 size,
11 './benchmarks/internal/thread/worker.js'
12)
325f50bc 13
292ad316
JB
14const fixedPoolLessRecentlyUsed = new FixedThreadPool(
15 size,
16 './benchmarks/internal/thread/worker.js',
17 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
18)
19
325f50bc
S
20async function fixedThreadTest (
21 { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } }
22) {
74750c7f 23 return runPoolifierTest(fixedPool, { tasks, workerData })
325f50bc
S
24}
25
292ad316
JB
26async function fixedThreadTestLessRecentlyUsed (
27 { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } }
28) {
29 return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData })
30}
31
32module.exports = { fixedThreadTest, fixedThreadTestLessRecentlyUsed }