1 const Benchmark
= require('benchmark')
4 dynamicClusterTestLessRecentlyUsed
5 } = require('./cluster/dynamic')
6 const { fixedClusterTest
} = require('./cluster/fixed')
9 dynamicThreadTestLessRecentlyUsed
10 } = require('./thread/dynamic')
11 const { fixedThreadTest
} = require('./thread/fixed')
13 const suite
= new Benchmark
.Suite('poolifier')
15 const LIST_FORMATTER
= new Intl
.ListFormat('en-US', {
20 // Wait some seconds before start, pools need to load threads !!!
21 setTimeout(async () => {
25 async
function test () {
28 .add('Poolifier:Static:ThreadPool', async
function () {
29 await
fixedThreadTest()
31 .add('Poolifier:Dynamic:ThreadPool', async
function () {
32 await
dynamicThreadTest()
34 .add('Poolifier:Dynamic:ThreadPool:LessRecentlyUsed', async
function () {
35 await
dynamicThreadTestLessRecentlyUsed()
37 .add('Poolifier:Static:ClusterPool', async
function () {
38 await
fixedClusterTest()
40 .add('Poolifier:Dynamic:ClusterPool', async
function () {
41 await
dynamicClusterTest()
43 .add('Poolifier:Dynamic:ClusterPool:LessRecentlyUsed', async
function () {
44 await
dynamicClusterTestLessRecentlyUsed()
47 .on('cycle', function (event
) {
48 console
.log(event
.target
.toString())
50 .on('complete', function () {
53 LIST_FORMATTER
.format(this.filter('fastest').map('name'))
55 // eslint-disable-next-line no-process-exit
58 .run({ async
: true, queued
: true })