You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
kotlinx.benchmark is a toolkit for running benchmarks for multiplatform code written in Kotlin and running on the following supported targets: JVM, JavaScript and Native.
11
+
kotlinx-benchmark is a toolkit for running benchmarks for multiplatform code written in Kotlin.
12
12
13
13
## Features
14
14
@@ -46,7 +46,7 @@ kotlinx.benchmark is a toolkit for running benchmarks for multiplatform code wri
46
46
47
47
## Using in Your Projects
48
48
49
-
The `kotlinx-benchmark` library is designed to work with Kotlin/JVM, Kotlin/JS, and Kotlin/Native targets. To get started, ensure you're using Kotlin 1.8.20 or newer and Gradle 8.0 or newer.
49
+
The `kotlinx-benchmark` library is designed to work with Kotlin/JVM, Kotlin/JS, Kotlin/Native, and Kotlin/WASM (experimental) targets. To get started, ensure you're using Kotlin 1.8.20 or newer and Gradle 8.0 or newer.
50
50
51
51
### Gradle Setup
52
52
@@ -149,7 +149,7 @@ You can alternatively mark your benchmark classes and methods `open` manually, b
149
149
150
150
#### Kotlin/JS
151
151
152
-
Specify a compiler like the [IR compiler](https://kotlinlang.org/docs/js-ir-compiler.html) and set benchmarking targets in one step. Here, `jsIr` and `jsIrBuiltIn` are both using the IR compiler. The former uses benchmark.js, while the latter uses Kotlin's built-in plugin.
152
+
Create a JS target with Node.js execution environment andregister it as a benchmark target:
153
153
154
154
```kotlin
155
155
kotlin {
@@ -159,9 +159,17 @@ kotlin {
159
159
js('jsIrBuiltIn', IR) {
160
160
nodejs()
161
161
}
162
+
benchmark {
163
+
targets {
164
+
register("jsIr")
165
+
register("jsIrBuiltIn")
166
+
}
167
+
}
162
168
}
163
169
```
164
170
171
+
This setup is using the [IR compiler](https://kotlinlang.org/docs/js-ir-compiler.html). `jsIr` and `jsIrBuiltIn` are both using the IR compiler. The former uses benchmark.js, while the latter uses Kotlin's built-in plugin.
172
+
165
173
#### Multiplatform
166
174
167
175
For multiplatform projects, add the `kotlinx-benchmark-runtime` dependency to the `commonMain` source set:
@@ -180,11 +188,9 @@ kotlin {
180
188
181
189
This setup enables running benchmarks in the main compilation of any registered targets. Another option is to register the compilation you want to run benchmarks from. The platform-specific artifacts will be resolved automatically. For a practical example, please refer to [examples](examples/multiplatform).
182
190
183
-
###BenchmarkConfiguration
191
+
Note:Benchmarkclasses located in the common source set will be run in all platforms, while those located in a platform-specific source set will be run in the corresponding platform.
184
192
185
-
In a `build.gradle` file create `benchmark` section, and inside it add a `targets` section.
186
-
Inthis section register all targets you want to run benchmarks from.
187
-
Examplefor multiplatform project:
193
+
Define your benchmark targets within the `benchmark` section in your `build.gradle` file:
0 commit comments