return this.findFirstFreeWorkerNodeKey()
}
+ /**
+ * Gets the worker task run time.
+ * If the required statistics are `avgRunTime`, the average run time is returned.
+ * If the required statistics are `medRunTime`, the median run time is returned.
+ *
+ * @param workerNodeKey - The worker node key.
+ * @returns The worker task run time.
+ */
+ protected getWorkerTaskRunTime (workerNodeKey: number): number {
+ return this.requiredStatistics.medRunTime
+ ? this.pool.workerNodes[workerNodeKey].tasksUsage.medRunTime
+ : this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime
+ }
+
/**
* Finds the first free worker node key based on the number of tasks the worker has applied.
*
workerNodeKey: number,
workerVirtualTaskStartTimestamp: number
): number {
- const workerVirtualTaskRunTime = this.requiredStatistics.medRunTime
- ? this.pool.workerNodes[workerNodeKey].tasksUsage.medRunTime
- : this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime
- return workerVirtualTaskStartTimestamp + workerVirtualTaskRunTime
+ return (
+ workerVirtualTaskStartTimestamp + this.getWorkerTaskRunTime(workerNodeKey)
+ )
}
private getWorkerVirtualTaskStartTimestamp (workerNodeKey: number): number {
if (workerVirtualTaskRunTime < workerWeight) {
this.workerVirtualTaskRunTime =
workerVirtualTaskRunTime +
- this.getWorkerVirtualTaskRunTime(chosenWorkerNodeKey)
+ this.getWorkerTaskRunTime(chosenWorkerNodeKey)
} else {
this.currentWorkerNodeId =
this.currentWorkerNodeId === this.pool.workerNodes.length - 1
return true
}
- private getWorkerVirtualTaskRunTime (workerNodeKey: number): number {
- return this.requiredStatistics.medRunTime
- ? this.pool.workerNodes[workerNodeKey].tasksUsage.medRunTime
- : this.pool.workerNodes[workerNodeKey].tasksUsage.avgRunTime
- }
-
private computeDefaultWorkerWeight (): number {
let cpusCycleTimeWeight = 0
for (const cpu of cpus()) {