Skip to content

Commit

Permalink
Accept an include filter in the JMH plugin.
Browse files Browse the repository at this point in the history
Signed-off-by: Kenneth J. Shackleton <[email protected]>
  • Loading branch information
kennethshackleton committed Jun 3, 2024
1 parent 7edee0f commit c18b0f2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions buildSrc/src/main/kotlin/JmhPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.gradle.api.Project
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.register

class JmhPlugin : Plugin<Project> {
override fun apply(target: Project): Unit = target.run {
Expand All @@ -35,15 +36,18 @@ class JmhPlugin : Plugin<Project> {
add(name, "org.openjdk.jmh:jmh-generator-annprocess:${Versions.JMH}")
}
}
tasks.register("jmh", JavaExec::class.java) {
tasks.register<JavaExec>("jmh") {
val reportDir = layout.buildDirectory.dir("reports/jmh")
val reportFile = layout.buildDirectory.file("reports/jmh/jmh.json")
group = "benchmark"
dependsOn("jmhClasses")
mainClass.set("org.openjdk.jmh.Main")
args(
"-rf", "json",
"-rff", reportFile.get().asFile.absolutePath
listOfNotNull(
properties["jmh.include"]?.toString(),
"-rf", "json",
"-rff", reportFile.get().asFile.absolutePath
)
)
classpath(sourceSets.getByName("jmh").runtimeClasspath)
doFirst { reportDir.get().asFile.mkdir() }
Expand Down

0 comments on commit c18b0f2

Please sign in to comment.