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'
14 } from '../benchmarks-utils.mjs'
16 const poolSize = availableParallelism()
17 const fixedThreadPool = buildPoolifierPool(
23 const taskExecutions = 1
25 function: TaskFunctions.jsonIntegerSerialization,
29 const poolifierSuite = new Benchmark.Suite('Poolifier')
31 for (const pool of [fixedThreadPool]) {
32 for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
33 for (const enableTasksQueue of [false, true]) {
35 `${pool.constructor.name}|${workerChoiceStrategy}|${
36 enableTasksQueue ? 'with' : 'without'
39 pool.setWorkerChoiceStrategy(workerChoiceStrategy)
40 pool.enableTasksQueue(enableTasksQueue)
42 pool.opts.workerChoiceStrategy,
45 assert.strictEqual(pool.opts.enableTasksQueue, enableTasksQueue)
46 await runPoolifierTest(pool, {
57 .on('cycle', event => {
58 console.info(event.target.toString())
60 .on('complete', function () {
62 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name'))
64 fixedThreadPool.destroy()