From 83e6c19681a5cae4b80773f95a66b6753b0bcd7e Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 30 Sep 2021 10:28:46 +0200 Subject: build: Migrate from kotlinx-benchmark to jmh-gradle This change updates the project to use jmh-gradle for benchmarking as opposed to kotlinx-benchmark. Both plugins use JMH under the hood, but jmh-gradle offers more options for profiling and seems to be beter maintained. --- buildSrc/build.gradle.kts | 2 +- .../main/kotlin/benchmark-conventions.gradle.kts | 38 +++------------------- gradle/libs.versions.toml | 4 --- .../opendc-simulator-resources/build.gradle.kts | 1 - 4 files changed, 6 insertions(+), 39 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index a5e99bfa..4eb8ac31 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -34,7 +34,7 @@ dependencies { implementation(kotlin("gradle-plugin", version = "1.5.30")) implementation("org.jlleitschuh.gradle:ktlint-gradle:10.1.0") implementation("org.jetbrains.kotlin:kotlin-allopen:1.5.30") - implementation("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.3.1") + implementation("me.champeau.jmh:jmh-gradle-plugin:0.6.6") implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.5.0") implementation("gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0") } diff --git a/buildSrc/src/main/kotlin/benchmark-conventions.gradle.kts b/buildSrc/src/main/kotlin/benchmark-conventions.gradle.kts index 590f51cf..65608e8f 100644 --- a/buildSrc/src/main/kotlin/benchmark-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/benchmark-conventions.gradle.kts @@ -20,49 +20,21 @@ * SOFTWARE. */ -import kotlinx.benchmark.gradle.* import org.jetbrains.kotlin.allopen.gradle.* plugins { - id("org.jetbrains.kotlinx.benchmark") `java-library` kotlin("plugin.allopen") -} - -sourceSets { - register("jmh") { - compileClasspath += sourceSets["main"].output - runtimeClasspath += sourceSets["main"].output - } -} - -configurations { - named("jmhImplementation") { - extendsFrom(configurations["implementation"]) - } + id("me.champeau.jmh") } configure { annotation("org.openjdk.jmh.annotations.State") } -benchmark { - targets { - register("jmh") { - this as JvmBenchmarkTarget - jmhVersion = "1.33" - } - } -} - -dependencies { - val libs = Libs(project) - implementation(libs["kotlinx.benchmark.runtime.jvm"]) -} +jmh { + jmhVersion.set("1.33") -// Workaround for https://github.com/Kotlin/kotlinx-benchmark/issues/39 -afterEvaluate { - tasks.named("jmhBenchmarkJar") { - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - } + profilers.add("stack") + profilers.add("gc") } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 82da905c..03402b9a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,6 @@ jackson = "2.12.5" junit-jupiter = "5.7.2" junit-platform = "1.7.2" kotlin-logging = "2.0.11" -kotlinx-benchmark = "0.3.1" kotlinx-coroutines = "1.5.1" ktor = "1.6.3" log4j = "2.14.1" @@ -65,9 +64,6 @@ ktor-client-auth = { module = "io.ktor:ktor-client-auth", version.ref = "ktor" } ktor-client-jackson = { module = "io.ktor:ktor-client-jackson", version.ref = "ktor" } ktor-client-mock = { module = "io.ktor:ktor-client-mock", version.ref = "ktor" } -# Benchmark -kotlinx-benchmark-runtime-jvm = { module = "org.jetbrains.kotlinx:kotlinx-benchmark-runtime-jvm", version.ref = "kotlinx-benchmark" } - # Other classgraph = { module = "io.github.classgraph:classgraph", version.ref = "classgraph" } hadoop-common = { module = "org.apache.hadoop:hadoop-common", version.ref = "hadoop" } diff --git a/opendc-simulator/opendc-simulator-resources/build.gradle.kts b/opendc-simulator/opendc-simulator-resources/build.gradle.kts index e4ffc3ff..68047d5c 100644 --- a/opendc-simulator/opendc-simulator-resources/build.gradle.kts +++ b/opendc-simulator/opendc-simulator-resources/build.gradle.kts @@ -34,6 +34,5 @@ dependencies { api(libs.kotlinx.coroutines) implementation(projects.opendcUtils) - jmhImplementation(projects.opendcSimulator.opendcSimulatorCore) testImplementation(projects.opendcSimulator.opendcSimulatorCore) } -- cgit v1.2.3