Commit | Line | Data |
---|---|---|
57df5469 | 1 | const Benchmark = require('benchmark') |
ff5e76e1 JB |
2 | const { |
3 | dynamicClusterTest, | |
4 | dynamicClusterTestLessRecentlyUsed | |
5 | } = require('./cluster/dynamic') | |
292ad316 JB |
6 | const { |
7 | fixedClusterTest, | |
8 | fixedClusterTestLessRecentlyUsed | |
9 | } = require('./cluster/fixed') | |
ff5e76e1 JB |
10 | const { |
11 | dynamicThreadTest, | |
12 | dynamicThreadTestLessRecentlyUsed | |
13 | } = require('./thread/dynamic') | |
292ad316 JB |
14 | const { |
15 | fixedThreadTest, | |
16 | fixedThreadTestLessRecentlyUsed | |
17 | } = require('./thread/fixed') | |
18 | const { LIST_FORMATTER } = require('./benchmark-utils') | |
325f50bc | 19 | |
ff5e76e1 | 20 | const suite = new Benchmark.Suite('poolifier') |
57df5469 | 21 | |
85a3f8a7 | 22 | // Wait some seconds before start, pools need to load threads !!! |
57df5469 | 23 | setTimeout(async () => { |
24 | test() | |
25 | }, 3000) | |
26 | ||
106744f7 | 27 | async function test () { |
85a3f8a7 | 28 | // Add tests |
cf9aa6c3 | 29 | suite |
292ad316 | 30 | .add('Poolifier:Fixed:ThreadPool', async function () { |
325f50bc S |
31 | await fixedThreadTest() |
32 | }) | |
292ad316 JB |
33 | .add('Poolifier:Fixed:ThreadPool:LessRecentlyUsed', async function () { |
34 | await fixedThreadTestLessRecentlyUsed() | |
35 | }) | |
ff5e76e1 | 36 | .add('Poolifier:Dynamic:ThreadPool', async function () { |
325f50bc S |
37 | await dynamicThreadTest() |
38 | }) | |
ff5e76e1 JB |
39 | .add('Poolifier:Dynamic:ThreadPool:LessRecentlyUsed', async function () { |
40 | await dynamicThreadTestLessRecentlyUsed() | |
41 | }) | |
292ad316 | 42 | .add('Poolifier:Fixed:ClusterPool', async function () { |
325f50bc | 43 | await fixedClusterTest() |
cf9aa6c3 | 44 | }) |
292ad316 JB |
45 | .add('Poolifier:Fixed:ClusterPool:LessRecentlyUsed', async function () { |
46 | await fixedClusterTestLessRecentlyUsed() | |
47 | }) | |
ff5e76e1 | 48 | .add('Poolifier:Dynamic:ClusterPool', async function () { |
325f50bc | 49 | await dynamicClusterTest() |
106744f7 | 50 | }) |
ff5e76e1 JB |
51 | .add('Poolifier:Dynamic:ClusterPool:LessRecentlyUsed', async function () { |
52 | await dynamicClusterTestLessRecentlyUsed() | |
53 | }) | |
85a3f8a7 | 54 | // Add listeners |
57df5469 | 55 | .on('cycle', function (event) { |
583a27ce | 56 | console.log(event.target.toString()) |
57df5469 | 57 | }) |
58 | .on('complete', function () { | |
583a27ce JB |
59 | console.log( |
60 | 'Fastest is ' + | |
61 | LIST_FORMATTER.format(this.filter('fastest').map('name')) | |
62 | ) | |
63 | // eslint-disable-next-line no-process-exit | |
64 | process.exit() | |
57df5469 | 65 | }) |
292ad316 | 66 | .run({ async: true }) |
57df5469 | 67 | } |