diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-06-15 21:56:01 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-06-15 22:04:10 +0200 |
| commit | f51bf570f143faf69e3ae361cceac5f0c2420d88 (patch) | |
| tree | 56df6529db005015240c7fd87b5eb7354fc019c2 | |
| parent | 5dc9ddf3dad048984ba8b60f6a375d0c5d2ef731 (diff) | |
fix(exp/tf20): Derive device statistics directly from SimMachine
This change updates the implementation of SimTFDevice to directly use
the metrics provided by the `SimBareMetalMachine` class, instead of
computing these metrics itself.
| -rw-r--r-- | opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt index 90350142..2c79da02 100644 --- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt +++ b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt @@ -68,13 +68,6 @@ public class SimTFDevice( ) /** - * Metrics collected by the device. - */ - private var _resourceUsage = 0.0 - private var _powerUsage = 0.0 - private var _energyUsage = 0.0 - - /** * The workload that will be run by the device. */ private val workload = object : SimWorkload, FlowSource { @@ -121,7 +114,7 @@ public class SimTFDevice( ctx = conn capacity = conn.capacity lastPull = now - conn.shouldSourceConverge = true + conn.shouldSourceConverge = false } override fun onPull(conn: FlowConnection, now: Long): Long { @@ -156,12 +149,6 @@ public class SimTFDevice( Long.MAX_VALUE } } - - override fun onConverge(conn: FlowConnection, now: Long) { - _resourceUsage = conn.rate - _powerUsage = machine.powerUsage - _energyUsage = machine.energyUsage - } } init { @@ -183,7 +170,8 @@ public class SimTFDevice( } override fun getDeviceStats(): TFDeviceStats { - return TFDeviceStats(_resourceUsage, _powerUsage, _energyUsage) + val resourceUsage = machine.cpus.sumOf { it.rate } + return TFDeviceStats(resourceUsage, machine.powerUsage, machine.energyUsage) } override fun close() { |
