diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-05-12 15:55:31 +0200 |
|---|---|---|
| committer | Georgios Andreadis <info@gandreadis.com> | 2020-05-12 15:55:31 +0200 |
| commit | bf98c6fcdd59787d196619febd0d99ce2dccda33 (patch) | |
| tree | bb289143b2767dd50047bb788252b14fabad6642 /opendc | |
| parent | 7e42d8e1a1ec23058af416548545fb06cfa3faa4 (diff) | |
Add test
Diffstat (limited to 'opendc')
2 files changed, 22 insertions, 9 deletions
diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/swf/SwfTraceReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/swf/SwfTraceReader.kt index 2de3a9db..7a2c704b 100644 --- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/swf/SwfTraceReader.kt +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/swf/SwfTraceReader.kt @@ -85,7 +85,6 @@ class SwfTraceReader( } .forEach { line -> val values = line.trim().split("\\s+".toRegex()) - println(values) jobNumber = values[jobNumberCol].trim().toLong() submitTime = values[submitTimeCol].trim().toLong() @@ -102,11 +101,12 @@ class SwfTraceReader( val flopsHistory = mutableListOf<FlopsHistoryFragment>() - // Insert waiting time + // Insert waiting time slices + // We ignore wait time remainders under one slicedWaitTime = 0L if (waitTime >= sliceDuration) { - for (tick in submitTime until waitTime step sliceDuration) { + for (tick in submitTime until (submitTime + waitTime - sliceDuration) step sliceDuration) { flopsHistory.add( FlopsHistoryFragment( tick * 1000L, 0L, sliceDuration * 1000L, 0.0, cores @@ -116,18 +116,19 @@ class SwfTraceReader( } } - // Insert run time + // Insert run time slices + flopsPerSecond = 4_000L * cores runtimePartialSliceRemainder = runTime % sliceDuration flopsPartialSlice = flopsPerSecond * runtimePartialSliceRemainder flopsFullSlice = flopsPerSecond * runTime - flopsPartialSlice for (tick in (submitTime + slicedWaitTime) - until (submitTime + slicedWaitTime + runTime) + until (submitTime + slicedWaitTime + runTime - sliceDuration) step sliceDuration) { flopsHistory.add( FlopsHistoryFragment( - tick * 1000L, flopsFullSlice / sliceDuration, sliceDuration * 1000L, 0.0, cores + tick * 1000L, flopsFullSlice / sliceDuration, sliceDuration * 1000L, 1.0, cores ) ) } @@ -136,7 +137,10 @@ class SwfTraceReader( flopsHistory.add( FlopsHistoryFragment( submitTime + (slicedWaitTime + runTime - runtimePartialSliceRemainder), - flopsPartialSlice, sliceDuration, 0.0, cores + flopsPartialSlice, + sliceDuration, + runtimePartialSliceRemainder / sliceDuration.toDouble(), + cores ) ) } diff --git a/opendc/opendc-format/src/test/kotlin/com/atlarge/opendc/format/trace/swf/SwfTraceReaderTest.kt b/opendc/opendc-format/src/test/kotlin/com/atlarge/opendc/format/trace/swf/SwfTraceReaderTest.kt index 0693c560..41ad8aba 100644 --- a/opendc/opendc-format/src/test/kotlin/com/atlarge/opendc/format/trace/swf/SwfTraceReaderTest.kt +++ b/opendc/opendc-format/src/test/kotlin/com/atlarge/opendc/format/trace/swf/SwfTraceReaderTest.kt @@ -8,7 +8,16 @@ class SwfTraceReaderTest { @Test internal fun testParseSwf() { val reader = SwfTraceReader(File(SwfTraceReaderTest::class.java.getResource("/swf_trace.txt").toURI())) - val entry = reader.next() - assertEquals(entry.submissionTime, 0) + var entry = reader.next() + assertEquals(0, entry.submissionTime) + // 1961 slices for waiting, 3 full and 1 partial running slices + assertEquals(1965, entry.workload.image.flopsHistory.toList().size) + + entry = reader.next() + assertEquals(164472, entry.submissionTime) + // 1188 slices for waiting, 0 full and 1 partial running slices + assertEquals(1189, entry.workload.image.flopsHistory.toList().size) + assertEquals(5_100_000L, entry.workload.image.flopsHistory.toList().last().flops) + assertEquals(0.25, entry.workload.image.flopsHistory.toList().last().usage) } } |
