feat: add less busy worker choice strategy
[poolifier.git] / benchmarks / internal / bench.js
CommitLineData
ca6c7d70 1const Benchmark = require('benny')
ff5e76e1
JB
2const {
3 dynamicClusterTest,
23ff945a 4 dynamicClusterTestFairShare,
168c526f 5 dynamicClusterTestLessUsed,
2d401b2d 6 dynamicClusterTestWeightedRoundRobin
ff5e76e1 7} = require('./cluster/dynamic')
292ad316
JB
8const {
9 fixedClusterTest,
23ff945a 10 fixedClusterTestFairShare,
168c526f 11 fixedClusterTestLessUsed,
2d401b2d 12 fixedClusterTestWeightedRoundRobin
292ad316 13} = require('./cluster/fixed')
ff5e76e1
JB
14const {
15 dynamicThreadTest,
23ff945a 16 dynamicThreadTestFairShare,
168c526f 17 dynamicThreadTestLessUsed,
2d401b2d 18 dynamicThreadTestWeightedRoundRobin
ff5e76e1 19} = require('./thread/dynamic')
292ad316
JB
20const {
21 fixedThreadTest,
23ff945a 22 fixedThreadTestFairShare,
168c526f 23 fixedThreadTestLessUsed,
2d401b2d 24 fixedThreadTestWeightedRoundRobin
292ad316 25} = require('./thread/fixed')
325f50bc 26
ca6c7d70
JB
27const resultsFile = 'poolifier'
28const resultsFolder = 'benchmarks/internal/results'
57df5469 29
ca6c7d70
JB
30Benchmark.suite(
31 'Poolifier',
32 Benchmark.add('Poolifier:Fixed:ThreadPool', async () => {
33 await fixedThreadTest()
34 }),
168c526f
JB
35 Benchmark.add('Poolifier:Fixed:ThreadPool:LessUsed', async () => {
36 await fixedThreadTestLessUsed()
ca6c7d70
JB
37 }),
38 Benchmark.add('Poolifier:Fixed:ThreadPool:WeightedRoundRobin', async () => {
39 await fixedThreadTestWeightedRoundRobin()
40 }),
41 Benchmark.add('Poolifier:Fixed:ThreadPool:FairShare', async () => {
42 await fixedThreadTestFairShare()
43 }),
44 Benchmark.add('Poolifier:Dynamic:ThreadPool', async () => {
45 await dynamicThreadTest()
46 }),
168c526f
JB
47 Benchmark.add('Poolifier:Dynamic:ThreadPool:LessUsed', async () => {
48 await dynamicThreadTestLessUsed()
ca6c7d70
JB
49 }),
50 Benchmark.add('Poolifier:Dynamic:ThreadPool:WeightedRoundRobin', async () => {
51 await dynamicThreadTestWeightedRoundRobin()
52 }),
53 Benchmark.add('Poolifier:Dynamic:ThreadPool:FairShare', async () => {
54 await dynamicThreadTestFairShare()
55 }),
56 Benchmark.add('Poolifier:Fixed:ClusterPool', async () => {
57 await fixedClusterTest()
58 }),
168c526f
JB
59 Benchmark.add('Poolifier:Fixed:ClusterPool:LessUsed', async () => {
60 await fixedClusterTestLessUsed()
ca6c7d70
JB
61 }),
62 Benchmark.add('Poolifier:Fixed:ClusterPool:WeightedRoundRobin', async () => {
63 await fixedClusterTestWeightedRoundRobin
64 }),
65 Benchmark.add('Poolifier:Fixed:ClusterPool:FairShare', async () => {
66 await fixedClusterTestFairShare()
67 }),
68 Benchmark.add('Poolifier:Dynamic:ClusterPool', async () => {
69 await dynamicClusterTest()
70 }),
168c526f
JB
71 Benchmark.add('Poolifier:Dynamic:ClusterPool:LessUsed', async () => {
72 await dynamicClusterTestLessUsed()
ca6c7d70
JB
73 }),
74 Benchmark.add(
75 'Poolifier:Dynamic:ClusterPool:WeightedRoundRobin',
76 async () => {
2d401b2d 77 await dynamicClusterTestWeightedRoundRobin
ca6c7d70
JB
78 }
79 ),
80 Benchmark.add('Poolifier:Dynamic:ClusterPool:FairShare', async () => {
81 await dynamicClusterTestFairShare()
82 }),
83 Benchmark.cycle(),
84 Benchmark.complete(),
85 Benchmark.save({
86 file: resultsFile,
87 folder: resultsFolder,
88 format: 'json',
89 details: true
90 }),
91 Benchmark.save({
92 file: resultsFile,
93 folder: resultsFolder,
94 format: 'chart.html',
95 details: true
96 }),
97 Benchmark.save({
98 file: resultsFile,
99 folder: resultsFolder,
100 format: 'table.html',
101 details: true
102 })
103)
18cac485
JB
104 .then(() => {
105 // eslint-disable-next-line n/no-process-exit
106 return process.exit()
107 })
108 .catch(err => console.error(err))