refactor: cleanup enums namespace
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 3 Jun 2023 21:08:23 +0000 (23:08 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 3 Jun 2023 21:08:23 +0000 (23:08 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
benchmarks/benchmarks-types.js
benchmarks/benchmarks-utils.js
benchmarks/internal/bench.js
package.json
pnpm-lock.yaml
tests/utils.test.js

index 7a951feece39d6580286f40201f5a51119248f31..4411fbbe3a4a39499e81bf45f5892905fafd7981 100644 (file)
@@ -6,13 +6,13 @@ const WorkerFunctions = {
 }
 
 const PoolTypes = {
-  FIXED: 'fixed',
-  DYNAMIC: 'dynamic'
+  fixed: 'fixed',
+  dynamic: 'dynamic'
 }
 
 const WorkerTypes = {
-  THREAD: 'thread',
-  CLUSTER: 'cluster'
+  thread: 'thread',
+  cluster: 'cluster'
 }
 
 module.exports = { PoolTypes, WorkerFunctions, WorkerTypes }
index 743936dabdbef3b1963fb63ce092b28881226d9b..eb3a4f945f40a64a95e010fe375b81c4bb874090 100644 (file)
@@ -114,15 +114,15 @@ function executeWorkerFunction (data) {
 
 function buildPool (workerType, poolType, poolSize, poolOptions) {
   switch (poolType) {
-    case PoolTypes.FIXED:
+    case PoolTypes.fixed:
       switch (workerType) {
-        case WorkerTypes.THREAD:
+        case WorkerTypes.thread:
           return new FixedThreadPool(
             poolSize,
             './benchmarks/internal/thread-worker.js',
             poolOptions
           )
-        case WorkerTypes.CLUSTER:
+        case WorkerTypes.cluster:
           return new FixedClusterPool(
             poolSize,
             './benchmarks/internal/cluster-worker.js',
@@ -130,16 +130,16 @@ function buildPool (workerType, poolType, poolSize, poolOptions) {
           )
       }
       break
-    case PoolTypes.DYNAMIC:
+    case PoolTypes.dynamic:
       switch (workerType) {
-        case WorkerTypes.THREAD:
+        case WorkerTypes.thread:
           return new DynamicThreadPool(
             poolSize / 2,
             poolSize * 3,
             './benchmarks/internal/thread-worker.js',
             poolOptions
           )
-        case WorkerTypes.CLUSTER:
+        case WorkerTypes.cluster:
           return new DynamicClusterPool(
             poolSize / 2,
             poolSize * 3,
index 94b49f13bd94233cb32f7330b73a444841c015e5..627bd0ed48d6e12f3c6ecda13ed3aad0a88990ba 100644 (file)
@@ -31,169 +31,169 @@ const workerChoiceStrategyFairSharePoolOption = {
 }
 
 const fixedThreadPoolRoundRobin = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.FIXED,
+  WorkerTypes.thread,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyRoundRobinPoolOption
 )
 
 const fixedThreadPoolRoundRobinTasksQueue = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.FIXED,
+  WorkerTypes.thread,
+  PoolTypes.fixed,
   poolSize,
   { ...workerChoiceStrategyRoundRobinPoolOption, ...tasksQueuePoolOption }
 )
 
 const fixedThreadPoolLeastUsed = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.FIXED,
+  WorkerTypes.thread,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyLeastUsedPoolOption
 )
 
 const fixedThreadPoolLeastBusy = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.FIXED,
+  WorkerTypes.thread,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyLeastBusyPoolOption
 )
 
 const fixedThreadPoolWeightedRoundRobin = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.FIXED,
+  WorkerTypes.thread,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyWeightedRoundRobinPoolOption
 )
 
 const fixedThreadPoolFairShare = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.FIXED,
+  WorkerTypes.thread,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyFairSharePoolOption
 )
 
 const fixedThreadPoolFairShareTasksQueue = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.FIXED,
+  WorkerTypes.thread,
+  PoolTypes.fixed,
   poolSize,
   { ...workerChoiceStrategyFairSharePoolOption, ...tasksQueuePoolOption }
 )
 
 const dynamicThreadPoolRoundRobin = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.thread,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyRoundRobinPoolOption
 )
 
 const dynamicThreadPoolLeastUsed = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.thread,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyLeastUsedPoolOption
 )
 
 const dynamicThreadPoolLeastBusy = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.thread,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyLeastBusyPoolOption
 )
 
 const dynamicThreadPoolWeightedRoundRobin = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.thread,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyWeightedRoundRobinPoolOption
 )
 
 const dynamicThreadPoolFairShare = buildPool(
-  WorkerTypes.THREAD,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.thread,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyFairSharePoolOption
 )
 
 const fixedClusterPoolRoundRobin = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.FIXED,
+  WorkerTypes.cluster,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyRoundRobinPoolOption
 )
 
 const fixedClusterPoolRoundRobinTasksQueue = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.FIXED,
+  WorkerTypes.cluster,
+  PoolTypes.fixed,
   poolSize,
   { ...workerChoiceStrategyRoundRobinPoolOption, ...tasksQueuePoolOption }
 )
 
 const fixedClusterPoolLeastUsed = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.FIXED,
+  WorkerTypes.cluster,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyLeastUsedPoolOption
 )
 
 const fixedClusterPoolLeastBusy = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.FIXED,
+  WorkerTypes.cluster,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyLeastBusyPoolOption
 )
 
 const fixedClusterPoolWeightedRoundRobin = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.FIXED,
+  WorkerTypes.cluster,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyWeightedRoundRobinPoolOption
 )
 
 const fixedClusterPoolFairShare = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.FIXED,
+  WorkerTypes.cluster,
+  PoolTypes.fixed,
   poolSize,
   workerChoiceStrategyFairSharePoolOption
 )
 
 const fixedClusterPoolFairShareTaskQueue = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.FIXED,
+  WorkerTypes.cluster,
+  PoolTypes.fixed,
   poolSize,
   { ...workerChoiceStrategyFairSharePoolOption, ...tasksQueuePoolOption }
 )
 
 const dynamicClusterPoolRoundRobin = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.cluster,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyRoundRobinPoolOption
 )
 
 const dynamicClusterPoolLeastUsed = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.cluster,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyLeastUsedPoolOption
 )
 
 const dynamicClusterPoolLeastBusy = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.cluster,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyLeastBusyPoolOption
 )
 
 const dynamicClusterPoolWeightedRoundRobin = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.cluster,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyWeightedRoundRobinPoolOption
 )
 
 const dynamicClusterPoolFairShare = buildPool(
-  WorkerTypes.CLUSTER,
-  PoolTypes.DYNAMIC,
+  WorkerTypes.cluster,
+  PoolTypes.dynamic,
   poolSize,
   workerChoiceStrategyFairSharePoolOption
 )
index f31c55197ca6debce90a30882a21f9358cb86f7f..2d9f8dc0c9e05d7570fa5c0cbbbf7d168cbc1928 100644 (file)
     "eslint-define-config": "^1.20.0",
     "eslint-import-resolver-typescript": "^3.5.5",
     "eslint-plugin-import": "^2.27.5",
-    "eslint-plugin-jsdoc": "^46.2.0",
+    "eslint-plugin-jsdoc": "^46.2.1",
     "eslint-plugin-n": "^16.0.0",
     "eslint-plugin-promise": "^6.1.1",
     "eslint-plugin-spellcheck": "^0.0.20",
index 9af8e2a777a1b343118ca7b2b755b30f56c45e50..003afd75f5428976b8525affe056c1d4f77cace3 100644 (file)
@@ -57,8 +57,8 @@ devDependencies:
     specifier: ^2.27.5
     version: 2.27.5(@typescript-eslint/parser@5.59.8)(eslint-import-resolver-typescript@3.5.5)(eslint@8.42.0)
   eslint-plugin-jsdoc:
-    specifier: ^46.2.0
-    version: 46.2.0(eslint@8.42.0)
+    specifier: ^46.2.1
+    version: 46.2.1(eslint@8.42.0)
   eslint-plugin-n:
     specifier: ^16.0.0
     version: 16.0.0(eslint@8.42.0)
@@ -2351,8 +2351,8 @@ packages:
       - supports-color
     dev: true
 
-  /eslint-plugin-jsdoc@46.2.0(eslint@8.42.0):
-    resolution: {integrity: sha512-Lo2Bs39UPtcvLGfBrI/RF+8mOPcYaHdj++YTfDrqrWHND2trGQBDKxCVcEyYACrQxyMYgpfqHkyxE0S184hOGg==}
+  /eslint-plugin-jsdoc@46.2.1(eslint@8.42.0):
+    resolution: {integrity: sha512-rsv3EE2FGDpYTSnIzDHpf9SsB7ccTmCl8dMcJzpBAOLiJ1maIMYMOfPDqT1IB+Y21muD894xhO6BTrOIvY5mfg==}
     engines: {node: '>=16'}
     peerDependencies:
       eslint: ^7.0.0 || ^8.0.0
index d4c2179b12a6ddba893aa771846a896bdccf1d7e..b1a91776a61ac63abefb10eea11ee11f19c1b29d 100644 (file)
@@ -6,7 +6,7 @@ const {
 } = require('../lib/worker/worker-options')
 
 describe('Utils test suite', () => {
-  it('Verify median computation', () => {
+  it('Verify median() computation', () => {
     expect(median([])).toBe(0)
     expect(median([0.08])).toBe(0.08)
     expect(median([0.25, 4.75, 3.05, 6.04, 1.01, 2.02, 5.03])).toBe(3.05)