summaryrefslogtreecommitdiff
path: root/opendc-simulator
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-05 17:06:09 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-10-05 17:06:09 +0200
commita6eec366f2a171f112a94d4ed50fe2c6521792a5 (patch)
treec979d9dd492b9c811eabb6f1797428dcb9012bff /opendc-simulator
parentbb5da0b8c3f6cea938b0630048af737ee05913ce (diff)
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.
Diffstat (limited to 'opendc-simulator')
-rw-r--r--opendc-simulator/opendc-simulator-flow/src/main/kotlin/org/opendc/simulator/flow/mux/MaxMinFlowMultiplexer.kt6
1 files changed, 3 insertions, 3 deletions
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]