1 const Benchmark
= require('benchmark')
2 const { dynamicClusterTest
} = require('./cluster/dynamic')
3 const { fixedClusterTest
} = require('./cluster/fixed')
4 const { dynamicThreadTest
} = require('./thread/dynamic')
5 const { fixedThreadTest
} = require('./thread/fixed')
7 const suite
= new Benchmark
.Suite()
9 const LIST_FORMATTER
= new Intl
.ListFormat('en-US', {
14 // Wait some seconds before start, pools need to load threads !!!
15 setTimeout(async () => {
19 async
function test () {
22 .add('Pioardi:Static:ThreadPool', async
function () {
23 await
fixedThreadTest()
25 .add('Pioardi:Dynamic:ThreadPool', async
function () {
26 await
dynamicThreadTest()
28 .add('Pioardi:Static:ClusterPool', async
function () {
29 await
fixedClusterTest()
31 .add('Pioardi:Dynamic:ClusterPool', async
function () {
32 await
dynamicClusterTest()
35 .on('cycle', function (event
) {
36 console
.log(event
.target
.toString())
38 .on('complete', function () {
41 LIST_FORMATTER
.format(this.filter('fastest').map('name'))
43 // eslint-disable-next-line no-process-exit