summaryrefslogtreecommitdiff
path: root/opendc-experiments/opendc-experiments-base/build.gradle.kts
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2026-05-21 16:52:31 +1000
committerGitHub <noreply@github.com>2026-05-21 16:52:31 +1000
commit5b4b6bde235e47fcc7074578673dfea1077771a7 (patch)
tree5a4dfbae02455cda92e90b21dfbbd413c3e27eae /opendc-experiments/opendc-experiments-base/build.gradle.kts
parentac6a11f2eb9e415b9f8782424d975adbd0d2ddd9 (diff)
Added Benchmarking tools (#413)
Added files for the smaller workload benchmarks Added benchmark examples Started implementing benchmarking functions
Diffstat (limited to 'opendc-experiments/opendc-experiments-base/build.gradle.kts')
-rw-r--r--opendc-experiments/opendc-experiments-base/build.gradle.kts38
1 files changed, 38 insertions, 0 deletions
diff --git a/opendc-experiments/opendc-experiments-base/build.gradle.kts b/opendc-experiments/opendc-experiments-base/build.gradle.kts
index 8a77f0c4..b22e4d41 100644
--- a/opendc-experiments/opendc-experiments-base/build.gradle.kts
+++ b/opendc-experiments/opendc-experiments-base/build.gradle.kts
@@ -29,10 +29,48 @@ plugins {
`jacoco-conventions`
distribution
kotlin("plugin.serialization") version "1.9.22"
+ id("me.champeau.jmh")
+}
+
+jmh {
+ resultFormat.set("JSON")
+ includes.add(".*WorkloadNoExportBenchmark.*")
+}
+
+tasks.named("jmh") {
+ doLast {
+ val resultsFile = layout.buildDirectory.file("results/jmh/results.json").get().asFile
+ val heapFile = layout.buildDirectory.file("heap-stats.csv").get().asFile
+ if (!resultsFile.exists() || !heapFile.exists()) return@doLast
+
+ val heapByBenchmark =
+ heapFile.readLines().associate { line ->
+ val cols = line.split(",")
+ cols[0].trim('"') to
+ mapOf(
+ "avgMb" to cols[1].toDouble(),
+ "avgStdMb" to cols[2].toDouble(),
+ "maxMb" to cols[3].toDouble(),
+ "maxStdMb" to cols[4].toDouble(),
+ )
+ }
+ heapFile.delete()
+
+ @Suppress("UNCHECKED_CAST")
+ val results = groovy.json.JsonSlurper().parse(resultsFile) as List<MutableMap<String, Any>>
+ for (entry in results) {
+ val benchmark = entry["benchmark"] as String
+ heapByBenchmark[benchmark]?.let { entry["heapMetric"] = it }
+ }
+
+ resultsFile.writeText(groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(results)))
+ }
}
dependencies {
+ implementation(kotlin("stdlib"))
+
api(projects.opendcCompute.opendcComputeSimulator)
implementation(libs.clikt)