perf: add measurement coverage to benchmark
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 23 Jul 2023 19:01:23 +0000 (21:01 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 23 Jul 2023 19:01:23 +0000 (21:01 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
benchmarks/benchmarks-types.mjs
benchmarks/benchmarks-utils.mjs
benchmarks/internal/bench.mjs

index dcffd1369c5e946967b44e2b46a97bf2668db522..3287cc3c85d377a91db2464a2d9fe84ecc6bd2a4 100644 (file)
@@ -1,10 +1,6 @@
-import { PoolTypes, WorkerTypes } from '../lib/index.mjs'
-
-const WorkerFunctions = {
+export const WorkerFunctions = {
   jsonIntegerSerialization: 'jsonIntegerSerialization',
   fibonacci: 'fibonacci',
   factorial: 'factorial',
   readWriteFiles: 'readWriteFiles'
 }
-
-export { PoolTypes, WorkerFunctions, WorkerTypes }
index 8819c59255eb4cb6925e7463760695c2872924e8..48c8fc3e7cb7dacd019a4ca3ac8fa28749c61db5 100644 (file)
@@ -4,9 +4,11 @@ import {
   DynamicClusterPool,
   DynamicThreadPool,
   FixedClusterPool,
-  FixedThreadPool
+  FixedThreadPool,
+  PoolTypes,
+  WorkerTypes
 } from '../lib/index.mjs'
-import { PoolTypes, WorkerFunctions, WorkerTypes } from './benchmarks-types.mjs'
+import { WorkerFunctions } from './benchmarks-types.mjs'
 
 export const runTest = async (pool, { taskExecutions, workerData }) => {
   return new Promise((resolve, reject) => {
index 41c035e6ae67bd8602433fd13bef5334ef23a089..48f30f66d0f47a14b1296b1279ebbee679309eb7 100644 (file)
@@ -1,13 +1,12 @@
 import { add, complete, cycle, save, suite } from 'benny'
 import {
+  Measurements,
+  PoolTypes,
   WorkerChoiceStrategies,
+  WorkerTypes,
   availableParallelism
 } from '../../lib/index.mjs'
-import {
-  PoolTypes,
-  WorkerFunctions,
-  WorkerTypes
-} from '../benchmarks-types.mjs'
+import { WorkerFunctions } from '../benchmarks-types.mjs'
 import { buildPool, runTest } from '../benchmarks-utils.mjs'
 
 const poolSize = availableParallelism()
@@ -18,26 +17,31 @@ for (const poolType of Object.values(PoolTypes)) {
       continue
     }
     for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
-      for (const tasksQueue of [false, true]) {
-        const pool = buildPool(
-          workerType,
-          poolType,
-          poolSize,
-          tasksQueue
-            ? {
-                ...{
-                  workerChoiceStrategy
-                },
-                ...{ enableTasksQueue: true }
-              }
-            : {
-                workerChoiceStrategy
-              }
-        )
-        pools.push([
-          `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${tasksQueue}`,
-          pool
-        ])
+      for (const enableTasksQueue of [false, true]) {
+        if (workerChoiceStrategy === WorkerChoiceStrategies.FAIR_SHARE) {
+          for (const measurement of [Measurements.runTime, Measurements.elu]) {
+            const pool = buildPool(workerType, poolType, poolSize, {
+              workerChoiceStrategy,
+              workerChoiceStrategyOptions: {
+                measurement
+              },
+              enableTasksQueue
+            })
+            pools.push([
+              `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${enableTasksQueue}|measurement:${measurement}`,
+              pool
+            ])
+          }
+        } else {
+          const pool = buildPool(workerType, poolType, poolSize, {
+            workerChoiceStrategy,
+            enableTasksQueue
+          })
+          pools.push([
+            `${poolType}|${workerType}|${workerChoiceStrategy}|tasks queue:${enableTasksQueue}`,
+            pool
+          ])
+        }
       }
     }
   }