- const deleted = this.workersTaskRunTime.delete(workerNodeKey)
- for (const [key, value] of this.workersTaskRunTime) {
- if (key > workerNodeKey) {
- this.workersTaskRunTime.set(key - 1, value)
- }
- }
- return deleted
- }
-
- private initWorkersTaskRunTime (): void {
- for (const [index] of this.pool.workerNodes.entries()) {
- this.initWorkerTaskRunTime(index)
- }
- }
-
- private initWorkerTaskRunTime (workerNodeKey: number): void {
- this.setWorkerTaskRunTime(workerNodeKey, this.defaultWorkerWeight, 0)
- }
-
- private setWorkerTaskRunTime (
- workerNodeKey: number,
- weight: number,
- runTime: number
- ): void {
- this.workersTaskRunTime.set(workerNodeKey, {
- weight,
- runTime
- })
- }
-
- private getWorkerVirtualTaskRunTime (workerNodeKey: number): number {
- return this.requiredStatistics.medRunTime
- ? this.pool.workerNodes[workerNodeKey].tasksUsage.medRunTime
- : this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime
- }
-
- private computeWorkerWeight (): number {
- let cpusCycleTimeWeight = 0
- for (const cpu of cpus()) {
- // CPU estimated cycle time
- const numberOfDigits = cpu.speed.toString().length - 1
- const cpuCycleTime = 1 / (cpu.speed / Math.pow(10, numberOfDigits))
- cpusCycleTimeWeight += cpuCycleTime * Math.pow(10, numberOfDigits)
- }
- return Math.round(cpusCycleTimeWeight / cpus().length)