|
| 1 | +## Overview of Tasks Provided by kotlinx-benchmark Gradle Plugin |
| 2 | + |
| 3 | +The kotlinx-benchmark plugin creates different Gradle tasks depending on how it is configured. |
| 4 | +For each pair of configuration profile and registered target a task is created to execute that profile on the respective platform. |
| 5 | +To learn more about configuration profiles, refer to [configuration-options.md](configuration-options.md). |
| 6 | + |
| 7 | +### Example Configuration |
| 8 | + |
| 9 | +To illustrate, consider the following `kotlinx-benchmark` configuration: |
| 10 | + |
| 11 | +```kotlin |
| 12 | +// build.gradle.kts |
| 13 | +benchmark { |
| 14 | + configurations { |
| 15 | + named("main") { |
| 16 | + iterations = 20 |
| 17 | + warmups = 20 |
| 18 | + iterationTime = 1 |
| 19 | + iterationTimeUnit = "s" |
| 20 | + } |
| 21 | + register("smoke") { |
| 22 | + include("Essential") |
| 23 | + iterations = 10 |
| 24 | + warmups = 10 |
| 25 | + iterationTime = 200 |
| 26 | + iterationTimeUnit = "ms" |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + targets { |
| 31 | + register("jvm") |
| 32 | + register("js") |
| 33 | + } |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +## Tasks for the "main" Configuration Profile |
| 38 | + |
| 39 | +- **`benchmark`**: |
| 40 | + - Runs benchmarks within the "main" profile for all registered targets. |
| 41 | + - In our example, `benchmark` runs benchmarks within the "main" profile in both `jvm` and `js` targets. |
| 42 | + |
| 43 | +- **`<targetName>Benchmark`**: |
| 44 | + - Runs benchmarks within the "main" profile for a particular target. |
| 45 | + - In our example, `jvmBenchmark` runs benchmarks within the "main" profile in the `jvm` target, while `jsBenchmark` runs them in the `js` target. |
| 46 | + |
| 47 | +## Tasks for Custom Configuration Profiles |
| 48 | + |
| 49 | +- **`<configName>Benchmark`**: |
| 50 | + - Runs benchmarks within `<configName>` profile in all registered targets. |
| 51 | + - In our example, `smokeBenchmark` runs benchmarks within the "smoke" profile. |
| 52 | + |
| 53 | +- **`<targetName><configName>Benchmark`**: |
| 54 | + - Runs benchmarks within `<configName>` profile in `<targetName>` target. |
| 55 | + - In our example, `jvmSmokeBenchmark` runs benchmarks within the "smoke" profile in `jvm` target while `jsSmokeBenchmark` runs them in `js` target. |
| 56 | + |
| 57 | +## Other useful tasks |
| 58 | + |
| 59 | +- **`<targetName>BenchmarkJar`**: |
| 60 | + - Created only when a Kotlin/JVM target is registered for benchmarking. |
| 61 | + - 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. |
| 62 | + - The JAR file can be run using `java -jar path-to-the.jar` command with relevant options. Run with `-h` to see the available options. |
| 63 | + - The JAR file can be used for running JMH profilers. |
| 64 | + - In our example, `jvmBenchmarkJar` produces a JAR file in `build/benchmarks/jvm/jars/` directory that contains benchmarks in `jvm` target. |
0 commit comments