Add benchmark for quick select algorithm evaluation. (#255)
[poolifier.git] / benchmarks / internal / cluster / dynamic.js
CommitLineData
ff5e76e1
JB
1const {
2 DynamicClusterPool,
3 WorkerChoiceStrategies
4} = require('../../../lib/index')
74750c7f 5const { runPoolifierTest } = require('../benchmark-utils')
325f50bc
S
6
7const size = 30
8
9const dynamicPool = new DynamicClusterPool(
10 size / 2,
11 size * 3,
1927ee67 12 './benchmarks/internal/cluster/worker.js'
325f50bc
S
13)
14
ff5e76e1
JB
15const dynamicPoolLessRecentlyUsed = new DynamicClusterPool(
16 size / 2,
17 size * 3,
18 './benchmarks/internal/cluster/worker.js',
19 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED }
20)
21
325f50bc
S
22async function dynamicClusterTest (
23 { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } }
24) {
74750c7f 25 return runPoolifierTest(dynamicPool, { tasks, workerData })
325f50bc
S
26}
27
ff5e76e1
JB
28async function dynamicClusterTestLessRecentlyUsed (
29 { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } }
30) {
74750c7f 31 return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData })
ff5e76e1
JB
32}
33
34module.exports = {
35 dynamicClusterTest,
36 dynamicClusterTestLessRecentlyUsed
37}