From: Jérôme Benoit Date: Mon, 10 Apr 2023 18:26:03 +0000 (+0200) Subject: feat: internal benchmark with worker tasks queue enabled X-Git-Tag: v2.4.7~17 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=869b1a456e8c16863528c7972264c75c49960ee4;p=poolifier.git feat: internal benchmark with worker tasks queue enabled Signed-off-by: Jérôme Benoit --- diff --git a/benchmarks/internal/bench.js b/benchmarks/internal/bench.js index 21864828..fb2fb07f 100644 --- a/benchmarks/internal/bench.js +++ b/benchmarks/internal/bench.js @@ -8,6 +8,7 @@ const { } = require('./cluster/dynamic') const { fixedClusterTest, + fixedClusterTasksQueueTest, fixedClusterTestFairShare, fixedClusterTestLessUsed, fixedClusterTestWeightedRoundRobin, @@ -22,6 +23,7 @@ const { } = require('./thread/dynamic') const { fixedThreadTest, + fixedThreadTasksQueueTest, fixedThreadTestFairShare, fixedThreadTestLessUsed, fixedThreadTestWeightedRoundRobin, @@ -36,6 +38,9 @@ Benchmark.suite( Benchmark.add('Poolifier:Fixed:ThreadPool', async () => { await fixedThreadTest() }), + Benchmark.add('Poolifier:Fixed:ThreadPoolTasksQueue', async () => { + await fixedThreadTasksQueueTest() + }), Benchmark.add('Poolifier:Fixed:ThreadPool:LessUsed', async () => { await fixedThreadTestLessUsed() }), @@ -66,6 +71,9 @@ Benchmark.suite( Benchmark.add('Poolifier:Fixed:ClusterPool', async () => { await fixedClusterTest() }), + Benchmark.add('Poolifier:Fixed:ClusterPoolTasksQueue', async () => { + await fixedClusterTasksQueueTest() + }), Benchmark.add('Poolifier:Fixed:ClusterPool:LessUsed', async () => { await fixedClusterTestLessUsed() }), diff --git a/benchmarks/internal/cluster/fixed.js b/benchmarks/internal/cluster/fixed.js index 7e31a838..5469c443 100644 --- a/benchmarks/internal/cluster/fixed.js +++ b/benchmarks/internal/cluster/fixed.js @@ -12,6 +12,12 @@ const fixedPool = new FixedClusterPool( './benchmarks/internal/cluster/worker.js' ) +const fixedPoolTasksQueue = new FixedClusterPool( + size, + './benchmarks/internal/cluster/worker.js', + { enableTasksQueue: true } +) + const fixedPoolLessUsed = new FixedClusterPool( size, './benchmarks/internal/cluster/worker.js', @@ -42,6 +48,12 @@ async function fixedClusterTest ( return runPoolifierTest(fixedPool, { tasks, workerData }) } +async function fixedClusterTasksQueueTest ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(fixedPoolTasksQueue, { tasks, workerData }) +} + async function fixedClusterTestLessUsed ( { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { @@ -68,6 +80,7 @@ async function fixedClusterTestFairShare ( module.exports = { fixedClusterTest, + fixedClusterTasksQueueTest, fixedClusterTestLessUsed, fixedClusterTestLessBusy, fixedClusterTestWeightedRoundRobin, diff --git a/benchmarks/internal/thread/fixed.js b/benchmarks/internal/thread/fixed.js index a4ba580e..c8be6feb 100644 --- a/benchmarks/internal/thread/fixed.js +++ b/benchmarks/internal/thread/fixed.js @@ -12,6 +12,12 @@ const fixedPool = new FixedThreadPool( './benchmarks/internal/thread/worker.js' ) +const fixedPoolTasksQueue = new FixedThreadPool( + size, + './benchmarks/internal/thread/worker.js', + { enableTasksQueue: true } +) + const fixedPoolLessUsed = new FixedThreadPool( size, './benchmarks/internal/thread/worker.js', @@ -42,6 +48,12 @@ async function fixedThreadTest ( return runPoolifierTest(fixedPool, { tasks, workerData }) } +async function fixedThreadTasksQueueTest ( + { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } +) { + return runPoolifierTest(fixedPoolTasksQueue, { tasks, workerData }) +} + async function fixedThreadTestLessUsed ( { tasks, workerData } = { tasks: numberOfTasks, workerData: { proof: 'ok' } } ) { @@ -68,6 +80,7 @@ async function fixedThreadTestFairShare ( module.exports = { fixedThreadTest, + fixedThreadTasksQueueTest, fixedThreadTestLessUsed, fixedThreadTestLessBusy, fixedThreadTestWeightedRoundRobin,