diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-09-02 22:18:12 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-09-21 11:31:15 +0200 |
| commit | a7510e0708b6e5435f8440e588c762d6e6cd8a22 (patch) | |
| tree | 4438a9069847abe4edc99bd5e22a6b8bba5d6cef /opendc-compute/opendc-compute-workload/src/main | |
| parent | d65978b5f3426280d1dd64105e8442f5d5d98b9e (diff) | |
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.
Diffstat (limited to 'opendc-compute/opendc-compute-workload/src/main')
| -rw-r--r-- | opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt | 14 |
1 files changed, 13 insertions, 1 deletions
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 @@ -223,6 +223,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. * * @param timestamp Timestamp at which the fragment starts (in epoch millis). @@ -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 } /** |
