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