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