1 import Benchmark from 'benchmark'
5 WorkerChoiceStrategies,
8 } from '../../lib/index.mjs'
9 import { TaskFunctions } from '../benchmarks-types.mjs'
14 } from '../benchmarks-utils.mjs'
16 const poolSize = availableParallelism()
18 for (const poolType of Object.values(PoolTypes)) {
19 for (const workerType of Object.values(WorkerTypes)) {
20 if (workerType === WorkerTypes.cluster) {
23 for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
24 for (const enableTasksQueue of [false]) {
25 if (workerChoiceStrategy === WorkerChoiceStrategies.FAIR_SHARE) {
26 for (const measurement of [Measurements.runTime, Measurements.elu]) {
28 `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${enableTasksQueue}|measurement:${measurement}`,
29 buildPoolifierPool(workerType, poolType, poolSize, {
31 workerChoiceStrategyOptions: {
40 `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${enableTasksQueue}`,
41 buildPoolifierPool(workerType, poolType, poolSize, {
52 const taskExecutions = 1
54 function: TaskFunctions.jsonIntegerSerialization,
58 const suite = new Benchmark.Suite('Poolifier')
59 for (const [name, pool] of pools) {
60 suite.add(name, async () => {
61 await runPoolifierTest(pool, {
69 .on('cycle', event => {
70 console.info(event.target.toString())
72 .on('complete', function () {
74 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name'))
76 // eslint-disable-next-line n/no-process-exit
79 .run({ async: true, maxTime: 120 })