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