build(deps-dev): apply updates
[poolifier.git] / benchmarks / internal / thread / fixed.js
CommitLineData
292ad316
JB
1const {
2 FixedThreadPool,
3 WorkerChoiceStrategies
4} = require('../../../lib/index')
d1a9aa41 5const { runPoolifierTest } = require('../../benchmarks-utils')
325f50bc
S
6
7const size = 30
e843b904 8const numberOfTasks = 1
325f50bc 9
ff5e76e1
JB
10const fixedPool = new FixedThreadPool(
11 size,
12 './benchmarks/internal/thread/worker.js'
13)
325f50bc 14
869b1a45
JB
15const fixedPoolTasksQueue = new FixedThreadPool(
16 size,
17 './benchmarks/internal/thread/worker.js',
18 { enableTasksQueue: true }
19)
20
168c526f 21const fixedPoolLessUsed = new FixedThreadPool(
292ad316
JB
22 size,
23 './benchmarks/internal/thread/worker.js',
737c6d97 24 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_USED }
292ad316
JB
25)
26
d4abc60a
JB
27const fixedPoolLessBusy = new FixedThreadPool(
28 size,
29 './benchmarks/internal/thread/worker.js',
30 { workerChoiceStrategy: WorkerChoiceStrategies.LESS_BUSY }
31)
32
2d401b2d
JB
33const fixedPoolWeightedRoundRobin = new FixedThreadPool(
34 size,
35 './benchmarks/internal/thread/worker.js',
36 { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
37)
38
23ff945a
JB
39const fixedPoolFairShare = new FixedThreadPool(
40 size,
41 './benchmarks/internal/thread/worker.js',
42 { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
43)
44
325f50bc 45async function fixedThreadTest (
e843b904 46 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
325f50bc 47) {
74750c7f 48 return runPoolifierTest(fixedPool, { tasks, workerData })
325f50bc
S
49}
50
869b1a45
JB
51async function fixedThreadTasksQueueTest (
52 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
53) {
54 return runPoolifierTest(fixedPoolTasksQueue, { tasks, workerData })
55}
56
168c526f 57async function fixedThreadTestLessUsed (
e843b904 58 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
292ad316 59) {
168c526f 60 return runPoolifierTest(fixedPoolLessUsed, { tasks, workerData })
292ad316
JB
61}
62
d4abc60a
JB
63async function fixedThreadTestLessBusy (
64 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
65) {
66 return runPoolifierTest(fixedPoolLessBusy, { tasks, workerData })
67}
68
2d401b2d
JB
69async function fixedThreadTestWeightedRoundRobin (
70 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
71) {
72 return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData })
73}
74
23ff945a
JB
75async function fixedThreadTestFairShare (
76 { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } }
77) {
78 return runPoolifierTest(fixedPoolFairShare, { tasks, workerData })
79}
80
81module.exports = {
82 fixedThreadTest,
869b1a45 83 fixedThreadTasksQueueTest,
168c526f 84 fixedThreadTestLessUsed,
d4abc60a 85 fixedThreadTestLessBusy,
2d401b2d
JB
86 fixedThreadTestWeightedRoundRobin,
87 fixedThreadTestFairShare
23ff945a 88}