feat: internal benchmark with worker tasks queue enabled
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 10 Apr 2023 18:26:03 +0000 (20:26 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 10 Apr 2023 18:26:03 +0000 (20:26 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
benchmarks/internal/bench.js
benchmarks/internal/cluster/fixed.js
benchmarks/internal/thread/fixed.js

index 218648281fca341b0566fe977f30d0acbe893321..fb2fb07f36351a88a3f8190e1b3c13c16f488f09 100644 (file)
@@ -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()
   }),
index 7e31a838eceaaa271abcc7cf9a277a70eb6bbc75..5469c4433237fbba796f1ed8819fd78735ac624f 100644 (file)
@@ -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,
index a4ba580e0210710915e184abaeb6951caf1c6fd2..c8be6feb17c3fe92a30602b58c3aaba8482f9bc3 100644 (file)
@@ -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,