perf: remove unneeded estimated cpu speed computation
[poolifier.git] / src / pools / utils.ts
index 2c021534baddd48b06f3c9b0a9aa7a7fbfa2d0cd..533ca9cc7c27e6a9dc066315aa2e9560536a5775 100644 (file)
@@ -1,5 +1,4 @@
 import cluster, { Worker as ClusterWorker } from 'node:cluster'
-import { randomInt } from 'node:crypto'
 import { existsSync } from 'node:fs'
 import { cpus } from 'node:os'
 import { env } from 'node:process'
@@ -102,15 +101,13 @@ const getDefaultWeights = (
 }
 
 const getDefaultWorkerWeight = (): number => {
-  const cpuSpeed = randomInt(500, 2500)
   let cpusCycleTimeWeight = 0
   for (const cpu of cpus()) {
     // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
     if (cpu.speed == null || cpu.speed === 0) {
       cpu.speed =
-        // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
-        cpus().find(cpu => cpu.speed != null && cpu.speed !== 0)?.speed ??
-        cpuSpeed
+        // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-non-null-assertion,
+        cpus().find(cpu => cpu.speed != null && cpu.speed !== 0)!.speed
     }
     // CPU estimated cycle time
     const numberOfDigits = cpu.speed.toString().length - 1