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 | |
292ad316 JB |
15 | const fixedPoolLessRecentlyUsed = new FixedThreadPool( |
16 | size, | |
17 | './benchmarks/internal/thread/worker.js', | |
18 | { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } | |
19 | ) | |
20 | ||
2d401b2d JB |
21 | const fixedPoolWeightedRoundRobin = new FixedThreadPool( |
22 | size, | |
23 | './benchmarks/internal/thread/worker.js', | |
24 | { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN } | |
25 | ) | |
26 | ||
23ff945a JB |
27 | const fixedPoolFairShare = new FixedThreadPool( |
28 | size, | |
29 | './benchmarks/internal/thread/worker.js', | |
30 | { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE } | |
31 | ) | |
32 | ||
325f50bc | 33 | async function fixedThreadTest ( |
e843b904 | 34 | { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } |
325f50bc | 35 | ) { |
74750c7f | 36 | return runPoolifierTest(fixedPool, { tasks, workerData }) |
325f50bc S |
37 | } |
38 | ||
292ad316 | 39 | async function fixedThreadTestLessRecentlyUsed ( |
e843b904 | 40 | { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } |
292ad316 JB |
41 | ) { |
42 | return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData }) | |
43 | } | |
44 | ||
2d401b2d JB |
45 | async function fixedThreadTestWeightedRoundRobin ( |
46 | { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } | |
47 | ) { | |
48 | return runPoolifierTest(fixedPoolWeightedRoundRobin, { tasks, workerData }) | |
49 | } | |
50 | ||
23ff945a JB |
51 | async function fixedThreadTestFairShare ( |
52 | { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } | |
53 | ) { | |
54 | return runPoolifierTest(fixedPoolFairShare, { tasks, workerData }) | |
55 | } | |
56 | ||
57 | module.exports = { | |
58 | fixedThreadTest, | |
2d401b2d JB |
59 | fixedThreadTestLessRecentlyUsed, |
60 | fixedThreadTestWeightedRoundRobin, | |
61 | fixedThreadTestFairShare | |
23ff945a | 62 | } |