Merge dependabot/npm_and_yarn/examples/typescript/http-server-pool/fastify-cluster...
[poolifier.git] / benchmarks / internal / bench.mjs
... / ...
CommitLineData
1import {
2 PoolTypes,
3 WorkerTypes,
4 availableParallelism
5} from '../../lib/index.mjs'
6import { TaskFunctions } from '../benchmarks-types.js'
7import {
8 buildPoolifierPool,
9 runPoolifierPoolBenchmark
10} from '../benchmarks-utils.js'
11
12const poolSize = availableParallelism()
13const taskExecutions = 1
14const workerData = {
15 function: TaskFunctions.jsonIntegerSerialization,
16 taskSize: 1000
17}
18
19// FixedThreadPool
20await runPoolifierPoolBenchmark(
21 'Poolifier FixedThreadPool',
22 buildPoolifierPool(WorkerTypes.thread, PoolTypes.fixed, poolSize),
23 {
24 taskExecutions,
25 workerData
26 }
27)
28
29// DynamicThreadPool
30await runPoolifierPoolBenchmark(
31 'Poolifier DynamicThreadPool',
32 buildPoolifierPool(WorkerTypes.thread, PoolTypes.dynamic, poolSize),
33 {
34 taskExecutions,
35 workerData
36 }
37)
38
39// FixedClusterPool
40await runPoolifierPoolBenchmark(
41 'Poolifier FixedClusterPool',
42 buildPoolifierPool(WorkerTypes.cluster, PoolTypes.fixed, poolSize),
43 {
44 taskExecutions,
45 workerData
46 }
47)
48
49// DynamicClusterPool
50await runPoolifierPoolBenchmark(
51 'Poolifier DynamicClusterPool',
52 buildPoolifierPool(WorkerTypes.cluster, PoolTypes.dynamic, poolSize),
53 {
54 taskExecutions,
55 workerData
56 }
57)