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 poolifierSuite = new Benchmark.Suite('Poolifier', {
18 console.info(event.target.toString())
20 onComplete: function () {
22 'Fastest is ' + LIST_FORMATTER.format(this.filter('fastest').map('name'))
27 const poolSize = availableParallelism()
28 const benchmarkSettings = []
29 for (const poolType of Object.values(PoolTypes)) {
30 for (const workerType of Object.values(WorkerTypes)) {
31 if (workerType === WorkerTypes.cluster) {
34 for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
35 for (const enableTasksQueue of [false, true]) {
36 if (workerChoiceStrategy === WorkerChoiceStrategies.FAIR_SHARE) {
37 for (const measurement of [Measurements.runTime, Measurements.elu]) {
38 benchmarkSettings.push([
39 `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${enableTasksQueue}|measurement:${measurement}`,
45 workerChoiceStrategyOptions: {
53 benchmarkSettings.push([
54 `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${enableTasksQueue}`,
69 const taskExecutions = 1
71 function: TaskFunctions.jsonIntegerSerialization,
81 ] of benchmarkSettings) {
82 poolifierSuite.add(name, async () => {
83 const pool = buildPoolifierPool(workerType, poolType, poolSize, poolOptions)
84 await runPoolifierTest(pool, {
92 poolifierSuite.run({ async: true })