Skip to content

Commit

Permalink
Merge pull request #531 from kennethshackleton/jmh-filter
Browse files Browse the repository at this point in the history
Accept an include filter in the JMH plugin.
  • Loading branch information
kennethshackleton authored Jun 3, 2024
2 parents 7edee0f + c18b0f2 commit 25876ff
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 25876ff

Please sign in to comment.