1 import assert from 'node:assert'
2 import Benchmark from 'benchmark'
5 WorkerChoiceStrategies,
8 } from '../../lib/index.mjs'
9 import { TaskFunctions } from '../benchmarks-types.mjs'
13 getPoolImplementationName,
15 } from '../benchmarks-utils.mjs'
17 const poolSize = availableParallelism()
18 const fixedThreadPool = buildPoolifierPool(
24 const taskExecutions = 1
26 function: TaskFunctions.jsonIntegerSerialization,
30 const poolifierSuite = new Benchmark.Suite('Poolifier')
32 for (const pool of [fixedThreadPool]) {
33 for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
34 for (const enableTasksQueue of [false, true]) {
36 `${getPoolImplementationName(pool)}|${workerChoiceStrategy}|${
37 enableTasksQueue ? 'with' : 'without'
40 pool.setWorkerChoiceStrategy(workerChoiceStrategy)
41 pool.enableTasksQueue(enableTasksQueue)
43 pool.opts.workerChoiceStrategy,
46 assert.strictEqual(pool.opts.enableTasksQueue, enableTasksQueue)
47 await runPoolifierTest(pool, {
58 .on('cycle', event => {
59 console.info(event.target.toString())
61 .on('complete', async function () {
63 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name'))
65 await fixedThreadPool.destroy()