Skip to content

Commit 311437c

Browse files
wldehqurbonzoda
authored andcommitted
Introduce a guide to setting up Kotlin/JVM and Java projects for benchmarking: docs/kotlin-jvm-project-setup.md
1 parent f5a7f25 commit 311437c

File tree

2 files changed

+315
-25
lines changed

2 files changed

+315
-25
lines changed

README.md

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
[![Maven Central](https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/kotlinx-benchmark-runtime.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.jetbrains.kotlinx%22%20AND%20a:%22kotlinx-benchmark-runtime%22)
88
[![Gradle Plugin Portal](https://img.shields.io/maven-metadata/v?label=Gradle%20Plugin&metadataUrl=https://plugins.gradle.org/m2/org/jetbrains/kotlinx/kotlinx-benchmark-plugin/maven-metadata.xml)](https://plugins.gradle.org/plugin/org.jetbrains.kotlinx.benchmark)
99

10-
kotlinx-benchmark is a toolkit for running benchmarks for multiplatform code written in Kotlin.
10+
`kotlinx-benchmark` is a toolkit for running benchmarks for multiplatform code written in Kotlin.
11+
It is designed to work with Kotlin/JVM, Kotlin/JS, Kotlin/Native, and Kotlin/Wasm (experimental) targets.
12+
13+
To get started, ensure you're using Kotlin 1.9.20 or newer and Gradle 7.4 or newer.
1114

1215
## Features
1316

@@ -19,8 +22,7 @@ kotlinx-benchmark is a toolkit for running benchmarks for multiplatform code wri
1922

2023
<!--- TOC -->
2124

22-
- [Using in Your Projects](#using-in-your-projects)
23-
- [Project Setup](#project-setup)
25+
- [Setting Up a Kotlin Multiplatform Project for Benchmarking](#setting-up-a-kotlin-multiplatform-project-for-benchmarking)
2426
- [Target-specific configurations](#target-specific-configurations)
2527
- [Kotlin/JVM](#kotlinjvm)
2628
- [Kotlin/JS](#kotlinjs)
@@ -42,17 +44,13 @@ kotlinx-benchmark is a toolkit for running benchmarks for multiplatform code wri
4244
- [Setting Up a Separate Source Set for Benchmarks](docs/separate-benchmark-source-set.md)
4345
- [Overview of Tasks Provided by kotlinx-benchmark Gradle Plugin](docs/tasks-overview.md)
4446

45-
## Using in Your Projects
46-
47-
The `kotlinx-benchmark` library is designed to work with Kotlin/JVM, Kotlin/JS, Kotlin/Native, and Kotlin/Wasm (experimental) targets.
48-
To get started, ensure you're using Kotlin 1.9.20 or newer and Gradle 7.4 or newer.
47+
## Setting Up a Kotlin Multiplatform Project for Benchmarking
4948

50-
### Project Setup
49+
To configure a Kotlin Multiplatform project for benchmarking, follow the steps below.
50+
If you want to benchmark only Kotlin/JVM and Java code, you may refer to our [comprehensive guide](docs/kotlin-jvm-project-setup.md)
51+
dedicated to setting up benchmarking in those specific project types.
5152

52-
Follow the steps below to set up a Kotlin Multiplatform project for benchmarking.
53-
54-
<details open>
55-
<summary>Kotlin DSL</summary>
53+
<details open><summary>Kotlin DSL</summary>
5654

5755
1. **Applying Benchmark Plugin**: Apply the benchmark plugin.
5856

@@ -98,10 +96,9 @@ Follow the steps below to set up a Kotlin Multiplatform project for benchmarking
9896
}
9997
```
10098

101-
</details>
99+
</details>
102100

103-
<details>
104-
<summary>Groovy DSL</summary>
101+
<details><summary>Groovy DSL</summary>
105102

106103
1. **Applying Benchmark Plugin**: Apply the benchmark plugin.
107104

@@ -147,7 +144,7 @@ Follow the steps below to set up a Kotlin Multiplatform project for benchmarking
147144
}
148145
```
149146

150-
</details>
147+
</details>
151148

152149
### Target-specific configurations
153150

@@ -191,8 +188,7 @@ To run benchmarks in Kotlin/JVM:
191188
}
192189
```
193190

194-
<details>
195-
<summary><b>Explanation</b></summary>
191+
<details><summary><b>Explanation</b></summary>
196192

197193
Assume that you've annotated each of your benchmark classes with `@State(Scope.Benchmark)`:
198194
@@ -208,8 +204,8 @@ To run benchmarks in Kotlin/JVM:
208204
}
209205
```
210206
211-
In Kotlin, classes are `final` by default, which means they can't be overridden.
212-
This is incompatible with the operation of the Java Microbenchmark Harness (JMH), which kotlinx-benchmark uses under the hood for running benchmarks on JVM.
207+
In Kotlin, classes are `final` by default, which means they can't be overridden.
208+
This conflicts with the Java Microbenchmark Harness (JMH) operation, which `kotlinx-benchmark` uses under the hood for running benchmarks on JVM.
213209
JMH requires benchmark classes and methods to be `open` to be able to generate subclasses and conduct the benchmark.
214210

215211
This is where the `allopen` plugin comes into play. With the plugin applied, any class annotated with `@State` is treated as `open`, which allows JMH to work as intended:
@@ -307,7 +303,8 @@ To run benchmarks in Kotlin/Wasm:
307303
}
308304
```
309305

310-
Note: Kotlin/Wasm is an experimental compilation target for Kotlin. It may be dropped or changed at any time.
306+
Note: Kotlin/Wasm is an experimental compilation target for Kotlin. It may be dropped or changed at any time. Refer to
307+
[Kotlin/Wasm documentation](https://kotlinlang.org/docs/wasm-overview.html) for up-to-date information about the target stability.
311308

312309
### Writing Benchmarks
313310

@@ -393,11 +390,11 @@ See [writing benchmarks](docs/writing-benchmarks.md) for a complete guide for wr
393390
To run your benchmarks in all registered platforms, run `benchmark` Gradle task in your project.
394391
To run only on a specific platform, run `<target-name>Benchmark`, e.g., `jvmBenchmark`.
395392

396-
For more details about the tasks created by the kotlinx-benchmark plugin, refer to [this guide](docs/tasks-overview.md).
393+
For more details about the tasks created by the `kotlinx-benchmark` plugin, refer to [this guide](docs/tasks-overview.md).
397394

398395
### Benchmark Configuration Profiles
399396

400-
The kotlinx-benchmark library provides the ability to create multiple configuration profiles. The `main` configuration is already created by the Toolkit.
397+
The `kotlinx-benchmark` library provides the ability to create multiple configuration profiles. The `main` configuration is already created by the toolkit.
401398
Additional profiles can be created as needed in the `configurations` section of the `benchmark` block:
402399

403400
```kotlin
@@ -430,9 +427,9 @@ Refer to our [detailed documentation](docs/separate-benchmark-source-set.md) on
430427

431428
## Examples
432429

433-
To help you better understand how to use the kotlinx-benchmark library, we've provided an [examples](examples) subproject.
430+
To help you better understand how to use the `kotlinx-benchmark` library, we've provided an [examples](examples) subproject.
434431
These examples showcase various use cases and offer practical insights into the library's functionality.
435432

436433
## Contributing
437434

438-
We welcome contributions to kotlinx-benchmark! If you want to contribute, please refer to our [Contribution Guidelines](CONTRIBUTING.md).
435+
We welcome contributions to `kotlinx-benchmark`! If you want to contribute, please refer to our [Contribution Guidelines](CONTRIBUTING.md).

0 commit comments

Comments
 (0)