refactor: cleanup benchmark code
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 10 Sep 2023 10:09:00 +0000 (12:09 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 10 Sep 2023 10:09:00 +0000 (12:09 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
benchmarks/versus-external-pools/dynamic-node-worker-threads-pool.mjs
benchmarks/versus-external-pools/dynamic-poolifier.mjs
benchmarks/versus-external-pools/fixed-poolifier.mjs
benchmarks/versus-external-pools/static-node-worker-threads-pool.mjs

index ed8285026c740b93cec25465f6c2835e9a53931f..08535b68e1eabc78d6c9fc2437c1244324a697e3 100644 (file)
@@ -10,13 +10,13 @@ const data = {
   taskSize: parseInt(process.env.TASK_SIZE)
 }
 
-const pool = new DynamicPool(size)
+const dynamicPool = new DynamicPool(size)
 
 async function run () {
   const promises = new Set()
   for (let i = 0; i < iterations; i++) {
     promises.add(
-      pool.exec({
+      dynamicPool.exec({
         task: functionToBench,
         param: data,
         timeout: 60000 // this is the same as poolifier default
index 4f6a8b407c43584df4a4272643e1193db3b423e9..33ac343caf58034fb0b80f494a7a2d65c932c082 100644 (file)
@@ -9,7 +9,7 @@ const data = {
   taskSize: parseInt(process.env.TASK_SIZE)
 }
 
-const dynamicPool = new DynamicThreadPool(
+const dynamicThreadPool = new DynamicThreadPool(
   Math.floor(size / 2),
   size,
   './workers/poolifier/function-to-bench-worker.mjs',
@@ -21,7 +21,7 @@ const dynamicPool = new DynamicThreadPool(
 async function run () {
   const promises = new Set()
   for (let i = 0; i < iterations; i++) {
-    promises.add(dynamicPool.execute(data))
+    promises.add(dynamicThreadPool.execute(data))
   }
   await Promise.all(promises)
   // eslint-disable-next-line n/no-process-exit
index cbc7410dc4a6419e344c57896b91a444bbd44ac3..7cfd651d3ee3f4a9ea7208348409c803408d756f 100644 (file)
@@ -9,7 +9,7 @@ const data = {
   taskSize: parseInt(process.env.TASK_SIZE)
 }
 
-const fixedPool = new FixedThreadPool(
+const fixedThreadPool = new FixedThreadPool(
   size,
   './workers/poolifier/function-to-bench-worker.mjs',
   {
@@ -20,7 +20,7 @@ const fixedPool = new FixedThreadPool(
 async function run () {
   const promises = new Set()
   for (let i = 0; i < iterations; i++) {
-    promises.add(fixedPool.execute(data))
+    promises.add(fixedThreadPool.execute(data))
   }
   await Promise.all(promises)
   // eslint-disable-next-line n/no-process-exit
index 3275d6f26e3a9a75574c4e0b961375a953fcf1f4..d37677cdb1294190d9663365e0a39d89d986b973 100644 (file)
@@ -10,7 +10,7 @@ const data = {
   taskSize: parseInt(process.env.TASK_SIZE)
 }
 
-const pool = new StaticPool({
+const staticPool = new StaticPool({
   size,
   task: functionToBench
 })
@@ -18,7 +18,7 @@ const pool = new StaticPool({
 async function run () {
   const promises = new Set()
   for (let i = 0; i < iterations; i++) {
-    promises.add(pool.exec(data))
+    promises.add(staticPool.exec(data))
   }
   await Promise.all(promises)
   // eslint-disable-next-line n/no-process-exit