summaryrefslogtreecommitdiff
path: root/opendc-trace
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-trace')
-rw-r--r--opendc-trace/opendc-trace-opendc/build.gradle.kts1
-rw-r--r--opendc-trace/opendc-trace-opendc/src/jmh/kotlin/org/opendc/trace/opendc/OdcVmTraceBenchmarks.kt87
2 files changed, 88 insertions, 0 deletions
diff --git a/opendc-trace/opendc-trace-opendc/build.gradle.kts b/opendc-trace/opendc-trace-opendc/build.gradle.kts
index 67568f48..fad6d9e7 100644
--- a/opendc-trace/opendc-trace-opendc/build.gradle.kts
+++ b/opendc-trace/opendc-trace-opendc/build.gradle.kts
@@ -25,6 +25,7 @@ description = "Support for OpenDC-specific trace formats"
/* Build configuration */
plugins {
`kotlin-library-conventions`
+ `benchmark-conventions`
}
dependencies {
diff --git a/opendc-trace/opendc-trace-opendc/src/jmh/kotlin/org/opendc/trace/opendc/OdcVmTraceBenchmarks.kt b/opendc-trace/opendc-trace-opendc/src/jmh/kotlin/org/opendc/trace/opendc/OdcVmTraceBenchmarks.kt
new file mode 100644
index 00000000..b9b22931
--- /dev/null
+++ b/opendc-trace/opendc-trace-opendc/src/jmh/kotlin/org/opendc/trace/opendc/OdcVmTraceBenchmarks.kt
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2022 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package org.opendc.trace.opendc
+
+import org.opendc.trace.conv.*
+import org.opendc.trace.spi.TraceFormat
+import org.openjdk.jmh.annotations.*
+import org.openjdk.jmh.infra.Blackhole
+import java.nio.file.Path
+import java.util.concurrent.TimeUnit
+
+/**
+ * Benchmarks for parsing traces in the OpenDC vm format.
+ */
+@State(Scope.Thread)
+@Fork(1)
+@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
+@Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS)
+class OdcVmTraceBenchmarks {
+ private lateinit var path: Path
+ private lateinit var format: TraceFormat
+
+ @Setup
+ fun setUp() {
+ path = Path.of("../../opendc-experiments/opendc-experiments-capelin/src/test/resources/trace/bitbrains-small")
+ format = OdcVmTraceFormat()
+ }
+
+ @Benchmark
+ fun benchmarkResourcesReader(bh: Blackhole) {
+ val reader = format.newReader(path, TABLE_RESOURCES, null)
+ try {
+ val idColumn = reader.resolve(RESOURCE_ID)
+ while (reader.nextRow()) {
+ bh.consume(reader.getString(idColumn))
+ }
+ } finally {
+ reader.close()
+ }
+ }
+
+ @Benchmark
+ fun benchmarkResourceStatesReader(bh: Blackhole) {
+ val reader = format.newReader(path, TABLE_RESOURCE_STATES, null)
+ try {
+ val idColumn = reader.resolve(RESOURCE_ID)
+ while (reader.nextRow()) {
+ bh.consume(reader.getString(idColumn))
+ }
+ } finally {
+ reader.close()
+ }
+ }
+
+ @Benchmark
+ fun benchmarkInterferenceGroupReader(bh: Blackhole) {
+ val reader = format.newReader(path, TABLE_INTERFERENCE_GROUPS, null)
+ try {
+ val scoreColumn = reader.resolve(INTERFERENCE_GROUP_SCORE)
+ while (reader.nextRow()) {
+ bh.consume(reader.getDouble(scoreColumn))
+ }
+ } finally {
+ reader.close()
+ }
+ }
+}