| 1 | const { |
| 2 | DynamicClusterPool, |
| 3 | WorkerChoiceStrategies |
| 4 | } = require('../../../lib/index') |
| 5 | const { runPoolifierTest } = require('../benchmark-utils') |
| 6 | |
| 7 | const size = 30 |
| 8 | |
| 9 | const dynamicPool = new DynamicClusterPool( |
| 10 | size / 2, |
| 11 | size * 3, |
| 12 | './benchmarks/internal/cluster/worker.js' |
| 13 | ) |
| 14 | |
| 15 | const dynamicPoolLessRecentlyUsed = new DynamicClusterPool( |
| 16 | size / 2, |
| 17 | size * 3, |
| 18 | './benchmarks/internal/cluster/worker.js', |
| 19 | { workerChoiceStrategy: WorkerChoiceStrategies.LESS_RECENTLY_USED } |
| 20 | ) |
| 21 | |
| 22 | async function dynamicClusterTest ( |
| 23 | { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } } |
| 24 | ) { |
| 25 | return runPoolifierTest(dynamicPool, { tasks, workerData }) |
| 26 | } |
| 27 | |
| 28 | async function dynamicClusterTestLessRecentlyUsed ( |
| 29 | { tasks, workerData } = { tasks: 1, workerData: { proof: 'ok' } } |
| 30 | ) { |
| 31 | return runPoolifierTest(dynamicPoolLessRecentlyUsed, { tasks, workerData }) |
| 32 | } |
| 33 | |
| 34 | module.exports = { |
| 35 | dynamicClusterTest, |
| 36 | dynamicClusterTestLessRecentlyUsed |
| 37 | } |