Commit | Line | Data |
---|---|---|
149fdbb9 | 1 | import { add, complete, cycle, save, suite } from 'benny' |
d09b37fc JB |
2 | import { |
3 | WorkerChoiceStrategies, | |
4 | availableParallelism | |
5 | } from '../../lib/index.mjs' | |
8f810074 JB |
6 | import { |
7 | PoolTypes, | |
23a6c28d JB |
8 | WorkerFunctions, |
9 | WorkerTypes | |
8f810074 JB |
10 | } from '../benchmarks-types.mjs' |
11 | import { buildPool, runTest } from '../benchmarks-utils.mjs' | |
cdace0e5 | 12 | |
d09b37fc | 13 | const poolSize = availableParallelism() |
149fdbb9 JB |
14 | const pools = [] |
15 | for (const poolType of Object.values(PoolTypes)) { | |
16 | for (const workerType of Object.values(WorkerTypes)) { | |
23a6c28d JB |
17 | if (workerType === WorkerTypes.cluster) { |
18 | continue | |
19 | } | |
149fdbb9 JB |
20 | for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) { |
21 | for (const tasksQueue of [false, true]) { | |
22 | const pool = buildPool( | |
23 | workerType, | |
24 | poolType, | |
25 | poolSize, | |
26 | tasksQueue | |
27 | ? { | |
28 | ...{ | |
29 | workerChoiceStrategy | |
30 | }, | |
31 | ...{ enableTasksQueue: true } | |
32 | } | |
33 | : { | |
34 | workerChoiceStrategy | |
35 | } | |
36 | ) | |
37 | pools.push([ | |
986b1d5a | 38 | `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${tasksQueue}`, |
149fdbb9 JB |
39 | pool |
40 | ]) | |
41 | } | |
42 | } | |
43 | } | |
44 | } | |
0819631d | 45 | |
cdace0e5 JB |
46 | const taskExecutions = 1 |
47 | const workerData = { | |
48 | function: WorkerFunctions.jsonIntegerSerialization, | |
49 | taskSize: 1000 | |
50 | } | |
149fdbb9 JB |
51 | const addPools = pools => |
52 | pools.map(([name, pool]) => { | |
53 | return add(name, async () => { | |
54 | await runTest(pool, { | |
55 | taskExecutions, | |
56 | workerData | |
57 | }) | |
58 | }) | |
59 | }) | |
325f50bc | 60 | |
ca6c7d70 JB |
61 | const resultsFile = 'poolifier' |
62 | const resultsFolder = 'benchmarks/internal/results' | |
149fdbb9 | 63 | suite( |
ca6c7d70 | 64 | 'Poolifier', |
149fdbb9 JB |
65 | ...addPools(pools), |
66 | cycle(), | |
67 | complete(), | |
68 | save({ | |
ca6c7d70 JB |
69 | file: resultsFile, |
70 | folder: resultsFolder, | |
71 | format: 'json', | |
72 | details: true | |
73 | }), | |
149fdbb9 | 74 | save({ |
ca6c7d70 JB |
75 | file: resultsFile, |
76 | folder: resultsFolder, | |
77 | format: 'chart.html', | |
78 | details: true | |
79 | }), | |
149fdbb9 | 80 | save({ |
ca6c7d70 JB |
81 | file: resultsFile, |
82 | folder: resultsFolder, | |
83 | format: 'table.html', | |
84 | details: true | |
85 | }) | |
86 | ) | |
18cac485 JB |
87 | .then(() => { |
88 | // eslint-disable-next-line n/no-process-exit | |
89 | return process.exit() | |
90 | }) | |
91 | .catch(err => console.error(err)) |