-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better support for JMH Profiler Configuration #146
Changes from all commits
bae25e0
454e2ad
ab8fe5b
60e1bb1
2db1cb3
452c353
f3e0b8a
dc09ae1
0964a23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package kotlinx.benchmark.integration | ||
|
||
import kotlin.test.* | ||
|
||
class JvmProfilerTest : GradleTest() { | ||
|
||
@Test | ||
fun testGcProfiler() { | ||
val runner = project("kotlin-multiplatform") { | ||
configuration("gcProfiler") { | ||
iterations = 1 | ||
iterationTime = 100 | ||
iterationTimeUnit = "ms" | ||
advanced("jvmProfiler", "gc") | ||
} | ||
} | ||
|
||
runner.run("jvmGcProfilerBenchmark") { | ||
assertOutputContains("gc.alloc.rate") | ||
assertOutputContains("BUILD SUCCESSFUL") | ||
} | ||
} | ||
|
||
@Test | ||
fun testStackProfilerEffect() { | ||
val runner = project("kotlin-multiplatform") { | ||
configuration("stackProfiler") { | ||
iterations = 1 | ||
iterationTime = 100 | ||
iterationTimeUnit = "ms" | ||
advanced("jvmProfiler", "stack") | ||
} | ||
} | ||
|
||
runner.run("jvmStackProfilerBenchmark") { | ||
assertOutputContains("stack") | ||
assertOutputContains("BUILD SUCCESSFUL") | ||
} | ||
} | ||
|
||
@Test | ||
fun testClProfiler() { | ||
val runner = project("kotlin-multiplatform") { | ||
configuration("clProfiler") { | ||
iterations = 1 | ||
iterationTime = 100 | ||
iterationTimeUnit = "ms" | ||
advanced("jvmProfiler", "cl") | ||
} | ||
} | ||
|
||
runner.run("jvmClProfilerBenchmark") { | ||
assertOutputContains("class.unload.norm") | ||
assertOutputContains("BUILD SUCCESSFUL") | ||
} | ||
} | ||
|
||
@Test | ||
fun testCompProfilerEffect() { | ||
val runner = project("kotlin-multiplatform") { | ||
configuration("compProfiler") { | ||
iterations = 1 | ||
iterationTime = 100 | ||
iterationTimeUnit = "ms" | ||
advanced("jvmProfiler", "comp") | ||
} | ||
} | ||
|
||
runner.run("jvmCompProfilerBenchmark") { | ||
assertOutputContains("compiler.time.profiled") | ||
assertOutputContains("BUILD SUCCESSFUL") | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,7 +228,12 @@ private fun validateConfig(config: BenchmarkConfiguration) { | |
"jsUseBridge" -> require(value is Boolean) { | ||
"Invalid value for 'jsUseBridge': '$value'. Expected a Boolean value." | ||
} | ||
else -> throw IllegalArgumentException("Invalid advanced option name: '$param'. Accepted options: \"nativeFork\", \"nativeGCAfterIteration\", \"jvmForks\", \"jsUseBridge\".") | ||
"jvmProfiler" -> { | ||
require(value.toString() in ValidOptions.jvmProfilers) { | ||
"Invalid value for 'jvmProfiler': '$value'. Accepted values: ${ValidOptions.jvmProfilers.joinToString(", ")}." | ||
} | ||
} | ||
else -> throw IllegalArgumentException("Invalid advanced option name: '$param'. Accepted options: \"nativeFork\", \"nativeGCAfterIteration\", \"jvmForks\", \"jsUseBridge\", \"jvmProfiler\".") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might make sense to extract the list of advanced option names into a property of the |
||
} | ||
} | ||
} | ||
|
@@ -244,6 +249,7 @@ private object ValidOptions { | |
) | ||
val modes = setOf("thrpt", "avgt", "Throughput", "AverageTime") | ||
val nativeForks = setOf("perBenchmark", "perIteration") | ||
val jvmProfilers = setOf("stack", "gc", "cl", "comp", "perf", "perfnorm", "perfasm", "xperfasm", " dtraceasm") | ||
} | ||
|
||
internal val Gradle.isConfigurationCacheAvailable | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please explain what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am currently unfamiliar. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The It makes sense to add a comment in the code explaining this. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,21 @@ fun main(args: Array<String>) { | |
} | ||
} | ||
|
||
val profilerName = config.advanced["jvmProfiler"] | ||
when (profilerName) { | ||
"gc" -> jmhOptions.addProfiler("gc") | ||
"stack" -> jmhOptions.addProfiler("stack") | ||
"cl" -> jmhOptions.addProfiler("cl") | ||
"comp" -> jmhOptions.addProfiler("comp") | ||
"perf" -> jmhOptions.addProfiler("perf") | ||
"perfnorm" -> jmhOptions.addProfiler("perfnorm") | ||
"perfasm" -> jmhOptions.addProfiler("perfasm") | ||
"xperfasm" -> jmhOptions.addProfiler("xperfasm") | ||
"dtraceasm" -> jmhOptions.addProfiler("dtraceasm") | ||
null -> {} | ||
else -> throw IllegalArgumentException("Invalid value for 'jvmProfiler': $profilerName. Accepted values: gc, stack, cl, comp") | ||
wldeh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
Comment on lines
+60
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can it be changed to the following?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Voting for
|
||
|
||
val reportFormat = ResultFormatType.valueOf(config.reportFormat.uppercase()) | ||
val reporter = BenchmarkProgress.create(config.traceFormat) | ||
val output = JmhOutputFormat(reporter, config.name) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When a profiler (e.g., Could you please ensure that the secondary result (if not empty) of each iteration is reported as well? |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the test above fails now. Because
jvmProfiler
was added to the "Accepted options":