From 25a98e335fc873c22d8dc5082c4f6021a9144b44 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 4 May 2021 14:07:27 +0200 Subject: 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. --- .../src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'opendc-simulator/opendc-simulator-compute/src') 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) { -- cgit v1.2.3