fix: ensure worker node is defined before emitting
[poolifier.git] / benchmarks / internal / bench.mjs
... / ...
CommitLineData
1import { exit } from 'node:process'
2import {
3 PoolTypes,
4 WorkerTypes,
5 availableParallelism
6} from '../../lib/index.mjs'
7import { TaskFunctions } from '../benchmarks-types.cjs'
8import { runPoolifierPoolBenchmark } from '../benchmarks-utils.cjs'
9
10const poolSize = availableParallelism()
11const taskExecutions = 1
12const workerData = {
13 function: TaskFunctions.jsonIntegerSerialization,
14 taskSize: 1000
15}
16
17// FixedThreadPool
18await runPoolifierPoolBenchmark(
19 'FixedThreadPool',
20 WorkerTypes.thread,
21 PoolTypes.fixed,
22 poolSize,
23 {
24 taskExecutions,
25 workerData
26 }
27)
28
29// DynamicThreadPool
30await runPoolifierPoolBenchmark(
31 'DynamicThreadPool',
32 WorkerTypes.thread,
33 PoolTypes.dynamic,
34 poolSize,
35 {
36 taskExecutions,
37 workerData
38 }
39)
40
41// FixedClusterPool
42await runPoolifierPoolBenchmark(
43 'FixedClusterPool',
44 WorkerTypes.cluster,
45 PoolTypes.fixed,
46 poolSize,
47 {
48 taskExecutions,
49 workerData
50 }
51)
52
53// DynamicClusterPool
54await runPoolifierPoolBenchmark(
55 'DynamicClusterPool',
56 WorkerTypes.cluster,
57 PoolTypes.dynamic,
58 poolSize,
59 {
60 taskExecutions,
61 workerData
62 }
63)
64
65exit()