From a6eec366f2a171f112a94d4ed50fe2c6521792a5 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 5 Oct 2021 17:06:09 +0200 Subject: perf(simulator): Only sort outputs on capacity change This change removes the sorting step for the outputs in the scheduling procedure for the max min multiplexer. This step is only necessary when the capacity of one of the outputs changes, which does not happen often. --- .../kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'opendc-simulator') diff --git a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt index c6aa94e2..97059e93 100644 --- a/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt +++ b/opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt @@ -327,6 +327,9 @@ public class MaxMinFlowMultiplexer( for (input in _activeInputs) { input.capacity = newCapacity } + + // Sort outputs by their capacity + _activeOutputs.sort() } /** @@ -408,9 +411,6 @@ public class MaxMinFlowMultiplexer( this.demand = demand this.rate = rate - // Sort all consumers by their capacity - activeOutputs.sort() - // Divide the requests over the available capacity of the input resources fairly for (i in activeOutputs.indices) { val output = activeOutputs[i] -- cgit v1.2.3