Skip to content

Commit 6556161

Browse files
wldehAbduqodiri Qurbonzoda
authored andcommitted
Introduce docs/kotlin-jvm-project-setup.md
1 parent d38f20c commit 6556161

File tree

2 files changed

+314
-25
lines changed

2 files changed

+314
-25
lines changed

README.md

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
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
[![IR](https://img.shields.io/badge/Kotlin%2FJS-IR%20supported-yellow)](https://kotl.in/jsirsupported)
1010

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

1315
## Features
1416

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

2123
<!--- TOC -->
2224

23-
- [Using in Your Projects](#using-in-your-projects)
24-
- [Project Setup](#project-setup)
25+
- [Setting Up a Kotlin Multiplatform Project for Benchmarking](#setting-up-a-kotlin-multiplatform-project-for-benchmarking)
2526
- [Target-specific configurations](#target-specific-configurations)
2627
- [Kotlin/JVM](#kotlinjvm)
2728
- [Kotlin/JS](#kotlinjs)
@@ -46,17 +47,13 @@ kotlinx-benchmark is a toolkit for running benchmarks for multiplatform code wri
4647
- [Compatibility Guide](docs/compatibility.md)
4748
- [Submitting issues and PRs](CONTRIBUTING.md)
4849

49-
## Using in Your Projects
50-
51-
The `kotlinx-benchmark` library is designed to work with Kotlin/JVM, Kotlin/JS, Kotlin/Native, and Kotlin/Wasm (experimental) targets.
52-
To get started, ensure you're using Kotlin 1.9.20 or newer and Gradle 7.4 or newer.
53-
54-
### Project Setup
50+
## Setting Up a Kotlin Multiplatform Project for Benchmarking
5551

56-
Follow the steps below to set up a Kotlin Multiplatform project for benchmarking.
52+
To configure a Kotlin Multiplatform project for benchmarking, follow the steps below.
53+
If you want to benchmark Kotlin/JVM or Java code, you may refer to our [comprehensive guide](docs/kotlin-jvm-project-setup.md)
54+
dedicated to setting up benchmarking in those specific project types.
5755

58-
<details open>
59-
<summary>Kotlin DSL</summary>
56+
<details open><summary>Kotlin DSL</summary>
6057

6158
1. **Applying Benchmark Plugin**: Apply the benchmark plugin.
6259

@@ -102,10 +99,9 @@ Follow the steps below to set up a Kotlin Multiplatform project for benchmarking
10299
}
103100
```
104101

105-
</details>
102+
</details>
106103

107-
<details>
108-
<summary>Groovy DSL</summary>
104+
<details><summary>Groovy DSL</summary>
109105

110106
1. **Applying Benchmark Plugin**: Apply the benchmark plugin.
111107

@@ -151,7 +147,7 @@ Follow the steps below to set up a Kotlin Multiplatform project for benchmarking
151147
}
152148
```
153149

154-
</details>
150+
</details>
155151

156152
### Target-specific configurations
157153

@@ -195,8 +191,7 @@ To run benchmarks in Kotlin/JVM:
195191
}
196192
```
197193

198-
<details>
199-
<summary><b>Explanation</b></summary>
194+
<details><summary><b>Explanation</b></summary>
200195

201196
Assume that you've annotated each of your benchmark classes with `@State(Scope.Benchmark)`:
202197
@@ -212,8 +207,8 @@ To run benchmarks in Kotlin/JVM:
212207
}
213208
```
214209
215-
In Kotlin, classes are `final` by default, which means they can't be overridden.
216-
This is incompatible with the operation of the Java Microbenchmark Harness (JMH), which kotlinx-benchmark uses under the hood for running benchmarks on JVM.
210+
In Kotlin, classes are `final` by default, which means they can't be overridden.
211+
This conflicts with the Java Microbenchmark Harness (JMH) operation, which `kotlinx-benchmark` uses under the hood for running benchmarks on JVM.
217212
JMH requires benchmark classes and methods to be `open` to be able to generate subclasses and conduct the benchmark.
218213

219214
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:
@@ -311,7 +306,8 @@ To run benchmarks in Kotlin/Wasm:
311306
}
312307
```
313308

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

316312
### Writing Benchmarks
317313

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

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

400396
### Benchmark Configuration Profiles
401397

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

405401
```kotlin
@@ -432,9 +428,9 @@ Refer to our [detailed documentation](docs/separate-benchmark-source-set.md) on
432428

433429
## Examples
434430

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

438434
## Contributing
439435

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

0 commit comments

Comments
 (0)