| 1 | import { exit } from 'node:process' |
| 2 | import { |
| 3 | PoolTypes, |
| 4 | WorkerTypes, |
| 5 | availableParallelism |
| 6 | } from '../../lib/index.mjs' |
| 7 | import { TaskFunctions } from '../benchmarks-types.cjs' |
| 8 | import { runPoolifierPoolBenchmark } from '../benchmarks-utils.cjs' |
| 9 | |
| 10 | const poolSize = availableParallelism() |
| 11 | const taskExecutions = 1 |
| 12 | const workerData = { |
| 13 | function: TaskFunctions.jsonIntegerSerialization, |
| 14 | taskSize: 1000 |
| 15 | } |
| 16 | |
| 17 | // FixedThreadPool |
| 18 | await runPoolifierPoolBenchmark( |
| 19 | 'FixedThreadPool', |
| 20 | WorkerTypes.thread, |
| 21 | PoolTypes.fixed, |
| 22 | poolSize, |
| 23 | { |
| 24 | taskExecutions, |
| 25 | workerData |
| 26 | } |
| 27 | ) |
| 28 | |
| 29 | // DynamicThreadPool |
| 30 | await runPoolifierPoolBenchmark( |
| 31 | 'DynamicThreadPool', |
| 32 | WorkerTypes.thread, |
| 33 | PoolTypes.dynamic, |
| 34 | poolSize, |
| 35 | { |
| 36 | taskExecutions, |
| 37 | workerData |
| 38 | } |
| 39 | ) |
| 40 | |
| 41 | // FixedClusterPool |
| 42 | await runPoolifierPoolBenchmark( |
| 43 | 'FixedClusterPool', |
| 44 | WorkerTypes.cluster, |
| 45 | PoolTypes.fixed, |
| 46 | poolSize, |
| 47 | { |
| 48 | taskExecutions, |
| 49 | workerData |
| 50 | } |
| 51 | ) |
| 52 | |
| 53 | // DynamicClusterPool |
| 54 | await runPoolifierPoolBenchmark( |
| 55 | 'DynamicClusterPool', |
| 56 | WorkerTypes.cluster, |
| 57 | PoolTypes.dynamic, |
| 58 | poolSize, |
| 59 | { |
| 60 | taskExecutions, |
| 61 | workerData |
| 62 | } |
| 63 | ) |
| 64 | |
| 65 | exit() |