Merge branch 'master' into feature/task-functions
[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.mjs'
7 import {
8 buildPoolifierPool,
9 runPoolifierPoolBenchmark
10 } from '../benchmarks-utils.mjs'
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 )