Skip to content

Commit

Permalink
Added debugging display of JMH properties
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Apr 14, 2024
1 parent ee104f1 commit f7698bc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,23 @@ jmh {
val outputDir = if (isCi) "${project.rootDir}/tmp" else "${project.rootDir}/jmh-reports"
resultsFile = project.file("${outputDir}/${name}.csv")
humanOutputFile = if (isCi) null else project.file("${outputDir}/${name}.txt")

// Output options when jmh task
if (project.gradle.startParameter.taskNames.contains("jmh")) {
val props = this::class.java.methods
.filter {
it.returnType.run { this == Property::class.java || this == ListProperty::class.java } &&
it.parameterCount == 0
}
.associate {
// All property names begin with "get" and are formatted with substring(3).
it.name.substring(3) to when (val value = it.invoke(this)) {
is Property<*> -> value.orNull
is ListProperty<*> -> value.orNull
else -> throw IllegalStateException("${value::class.java} is not Property")
}
}

logger.log(LogLevel.LIFECYCLE, "> JMH props:\n$props")
}
}

0 comments on commit f7698bc

Please sign in to comment.