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'
}
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