1 const Benchmark
= require('benchmark')
4 dynamicClusterTestLessRecentlyUsed
5 } = require('./cluster/dynamic')
8 fixedClusterTestLessRecentlyUsed
9 } = require('./cluster/fixed')
12 dynamicThreadTestLessRecentlyUsed
13 } = require('./thread/dynamic')
16 fixedThreadTestLessRecentlyUsed
17 } = require('./thread/fixed')
18 const { LIST_FORMATTER
} = require('./benchmark-utils')
20 const suite
= new Benchmark
.Suite('poolifier')
22 // Wait some seconds before start, pools need to load threads !!!
23 setTimeout(async () => {
27 async
function test () {
30 .add('Poolifier:Fixed:ThreadPool', async
function () {
31 await
fixedThreadTest()
33 .add('Poolifier:Fixed:ThreadPool:LessRecentlyUsed', async
function () {
34 await
fixedThreadTestLessRecentlyUsed()
36 .add('Poolifier:Dynamic:ThreadPool', async
function () {
37 await
dynamicThreadTest()
39 .add('Poolifier:Dynamic:ThreadPool:LessRecentlyUsed', async
function () {
40 await
dynamicThreadTestLessRecentlyUsed()
42 .add('Poolifier:Fixed:ClusterPool', async
function () {
43 await
fixedClusterTest()
45 .add('Poolifier:Fixed:ClusterPool:LessRecentlyUsed', async
function () {
46 await
fixedClusterTestLessRecentlyUsed()
48 .add('Poolifier:Dynamic:ClusterPool', async
function () {
49 await
dynamicClusterTest()
51 .add('Poolifier:Dynamic:ClusterPool:LessRecentlyUsed', async
function () {
52 await
dynamicClusterTestLessRecentlyUsed()
55 .on('cycle', function (event
) {
56 console
.log(event
.target
.toString())
58 .on('complete', function () {
61 LIST_FORMATTER
.format(this.filter('fastest').map('name'))
63 // eslint-disable-next-line no-process-exit