summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-04 14:07:27 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-04 14:13:13 +0200
commit25a98e335fc873c22d8dc5082c4f6021a9144b44 (patch)
tree638f5a920570a3f49eb7ee44a505a6813af30dcb /opendc-simulator/opendc-simulator-compute
parent1ce1210be893e7333dfa09266f6990af87c98dc2 (diff)
simulator: Update power draw on machine draw
This change fixes an issue where the power draw of a machine is initially zero and does not update until the CPU usage is higher than zero, while the idle power is the machine is not actually zero.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt3
1 files changed, 3 insertions, 0 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt
index 0244c5c1..f6324e13 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt
@@ -85,6 +85,9 @@ public abstract class SimAbstractMachine(private val clock: Clock) : SimMachine
_speed = DoubleArray(model.cpus.size) { 0.0 }
var totalSpeed = 0.0
+ // Before the workload starts, initialize the initial power draw
+ updateUsage(0.0)
+
workload.onStart(ctx)
for (cpu in cpus) {