WorkerUsage
} from './worker'
import {
+ type MeasurementStatisticsRequirements,
Measurements,
WorkerChoiceStrategies,
type WorkerChoiceStrategy,
workerUsage: WorkerUsage,
message: MessageValue<Response>
): void {
+ const eluTaskStatisticsRequirements: MeasurementStatisticsRequirements =
+ this.workerChoiceStrategyContext.getTaskStatisticsRequirements().elu
updateMeasurementStatistics(
workerUsage.elu.active,
- this.workerChoiceStrategyContext.getTaskStatisticsRequirements().elu,
+ eluTaskStatisticsRequirements,
message.taskPerformance?.elu?.active ?? 0,
workerUsage.tasks.executed
)
updateMeasurementStatistics(
workerUsage.elu.idle,
- this.workerChoiceStrategyContext.getTaskStatisticsRequirements().elu,
+ eluTaskStatisticsRequirements,
message.taskPerformance?.elu?.idle ?? 0,
workerUsage.tasks.executed
)
- if (
- this.workerChoiceStrategyContext.getTaskStatisticsRequirements().elu
- .aggregate
- ) {
+ if (eluTaskStatisticsRequirements.aggregate) {
if (message.taskPerformance?.elu != null) {
if (workerUsage.elu.utilization != null) {
workerUsage.elu.utilization =
* @param measurementStatistics - The measurement statistics to update.
* @param measurementRequirements - The measurement statistics requirements.
* @param measurementValue - The measurement value.
- * @param tasksExecuted - The number of tasks executed.
+ * @param numberOfMeasurements - The number of measurements.
*/
export const updateMeasurementStatistics = (
measurementStatistics: MeasurementStatistics,
measurementRequirements: MeasurementStatisticsRequirements,
measurementValue: number,
- tasksExecuted: number
+ numberOfMeasurements: number
): void => {
if (measurementRequirements.aggregate) {
measurementStatistics.aggregate =
measurementValue,
measurementStatistics.maximum ?? -Infinity
)
- if (measurementRequirements.average && tasksExecuted !== 0) {
+ if (measurementRequirements.average && numberOfMeasurements !== 0) {
measurementStatistics.average =
- measurementStatistics.aggregate / tasksExecuted
+ measurementStatistics.aggregate / numberOfMeasurements
}
if (measurementRequirements.median && measurementValue != null) {
measurementStatistics.history.push(measurementValue)