From a7510e0708b6e5435f8440e588c762d6e6cd8a22 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 2 Sep 2022 22:18:12 +0200 Subject: refactor(sim/compute): Remove timestamp parameter from SimTrace This change removes the timestamp parameter from `SimTrace`. Instead, it is now assumed that the trace is continuous and the end of a fragment starts a new fragment, in order to simplify replaying of the trace. --- .../org/opendc/compute/workload/ComputeWorkloadLoader.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'opendc-compute') diff --git a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt index 12c2325a..7ed04994 100644 --- a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt +++ b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt @@ -222,6 +222,11 @@ public class ComputeWorkloadLoader(private val baseDir: File) { */ private val builder = SimTrace.builder() + /** + * The deadline of the previous fragment. + */ + private var previousDeadline = Long.MIN_VALUE + /** * Add a fragment to the trace. * @@ -233,7 +238,14 @@ public class ComputeWorkloadLoader(private val baseDir: File) { fun add(timestamp: Long, deadline: Long, usage: Double, cores: Int) { val duration = max(0, deadline - timestamp) totalLoad += (usage * duration) / 1000.0 // avg MHz * duration = MFLOPs - builder.add(timestamp, deadline, usage, cores) + + if (timestamp != previousDeadline) { + // There is a gap between the previous and current fragment; fill the gap + builder.add(timestamp, 0.0, cores) + } + + builder.add(deadline, usage, cores) + previousDeadline = deadline } /** -- cgit v1.2.3