From 282f199e6f16350123a915b06faff62ca82be91b Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 15 Jun 2022 22:01:34 +0200 Subject: fix(sim/compute): Always recompute power usage This change fixes an issue in the `SimBareMetalMachine` implementation where the power usage was only updated after a non-zero duration. However, this would mean that OpenDC would possibly report incorrect power usage values when multiple convergence calls occured at the same timestamp. --- .../main/kotlin/org/opendc/simulator/compute/SimBareMetalMachine.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'opendc-simulator') diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimBareMetalMachine.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimBareMetalMachine.kt index 68792c72..63a82e78 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimBareMetalMachine.kt +++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimBareMetalMachine.kt @@ -91,8 +91,9 @@ public class SimBareMetalMachine( if (duration > 0) { // Compute the power and energy usage of the machine computeEnergyUsage(now) - _powerUsage = powerDriverLogic.computePower() } + + _powerUsage = powerDriverLogic.computePower() } init { -- cgit v1.2.3