The kotlinx-benchmark plugin creates different Gradle tasks depending on how it is configured. For each pair of configuration profile and registered target a task is created to execute that profile on the respective platform. To learn more about configuration profiles, refer to configuration-options.md.
To illustrate, consider the following kotlinx-benchmark configuration:
// build.gradle.kts
benchmark {
configurations {
named("main") {
iterations = 20
warmups = 20
iterationTime = 1
iterationTimeUnit = "s"
}
register("smoke") {
include("Essential")
iterations = 10
warmups = 10
iterationTime = 200
iterationTimeUnit = "ms"
}
}
targets {
register("jvm")
register("js")
}
}-
benchmark:- Runs benchmarks within the "main" profile for all registered targets.
- In our example,
benchmarkruns benchmarks within the "main" profile in bothjvmandjstargets.
-
<targetName>Benchmark:- Runs benchmarks within the "main" profile for a particular target.
- In our example,
jvmBenchmarkruns benchmarks within the "main" profile in thejvmtarget, whilejsBenchmarkruns them in thejstarget.
-
<configName>Benchmark:- Runs benchmarks within
<configName>profile in all registered targets. - In our example,
smokeBenchmarkruns benchmarks within the "smoke" profile.
- Runs benchmarks within
-
<targetName><configName>Benchmark:- Runs benchmarks within
<configName>profile in<targetName>target. - In our example,
jvmSmokeBenchmarkruns benchmarks within the "smoke" profile injvmtarget whilejsSmokeBenchmarkruns them injstarget.
- Runs benchmarks within
<targetName>BenchmarkJar:- Created only when a Kotlin/JVM target is registered for benchmarking.
- Produces a self-contained executable JAR file in
build/benchmarks/<targetName>/jars/directory of your project that contains your benchmarks in<targetName>target, and all essential JMH infrastructure code. - The JAR file can be run using
java -jar path-to-the.jarcommand with relevant options. Run with-hto see the available options. - The JAR file can be used for running JMH profilers.
- In our example,
jvmBenchmarkJarproduces a JAR file inbuild/benchmarks/jvm/jars/directory that contains benchmarks injvmtarget.