| 1 | const { |
| 2 | FixedThreadPool, |
| 3 | WorkerChoiceStrategies |
| 4 | } = require('../../../lib/index') |
| 5 | const { runPoolifierTest } = require('../benchmark-utils') |
| 6 | |
| 7 | const size = 30 |
| 8 | |
| 9 | const fixedPool = new FixedThreadPool( |
| 10 | size, |
| 11 | './benchmarks/internal/thread/worker.js' |
| 12 | ) |
| 13 | |
| 14 | const fixedPoolLessRecentlyUsed = new FixedThreadPool( |
| 15 | size, |
| 16 | './benchmarks/internal/thread/worker.js', |
| 17 | { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } |
| 18 | ) |
| 19 | |
| 20 | async function fixedThreadTest ( |
| 21 | { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } } |
| 22 | ) { |
| 23 | return runPoolifierTest(fixedPool, { tasks, workerData }) |
| 24 | } |
| 25 | |
| 26 | async function fixedThreadTestLessRecentlyUsed ( |
| 27 | { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } } |
| 28 | ) { |
| 29 | return runPoolifierTest(fixedPoolLessRecentlyUsed, { tasks, workerData }) |
| 30 | } |
| 31 | |
| 32 | module.exports = { fixedThreadTest, fixedThreadTestLessRecentlyUsed } |