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
Copy file name to clipboardExpand all lines: docs/separate-benchmark-module.md
+20-8Lines changed: 20 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
-
# Creating Separate Module for Benchmarks
1
+
# Setting Up a Separate Source Set for Benchmarks
2
2
3
-
This guide will walk you through the process of creating a separate module for benchmarks in your Kotlin project.
4
-
Creating a separate module for benchmarks is especially beneficial when you are integrating benchmarks into an existing project.
3
+
This guide will walk you through the process of establishing a dedicated source set for benchmarks within your Kotlin project.
4
+
This approach is especially beneficial when you are integrating benchmarks into an existing project.
5
5
Here are a couple of advantages of doing so:
6
6
7
-
1.**Flexibility**: Creating a separate module allows you to manage your benchmarking code independently. You can compile, test, and run benchmarks without impacting your main source code.
7
+
1.**Flexibility**: Setting up a separate source set allows you to manage your benchmarking code independently. You can compile, test, and run benchmarks without impacting your main source code.
8
8
9
9
2.**Organization**: It helps maintain a clean and organized project structure. Segregating benchmarks from the main code makes it easier to navigate and locate specific code segments.
10
10
11
11
## Step-by-step Setup Guide
12
12
13
-
Below are the step-by-step instructions to set up a separate module for benchmarks in both Kotlin Multiplatform and Kotlin/JVM projects:
13
+
Below are the step-by-step instructions to set up a separate source set for benchmarks in both Kotlin Multiplatform and Kotlin/JVM projects:
14
14
15
15
### Kotlin Multiplatform Project
16
16
17
-
Follow these steps to set up a separate compilation for benchmarks:
17
+
Follow these steps to set up a separate source set for benchmarks:
18
18
19
19
1.**Define New Compilation**
20
20
@@ -37,7 +37,7 @@ Follow these steps to set up a separate compilation for benchmarks:
37
37
38
38
2. **RegisterBenchmarkCompilation**
39
39
40
-
Conclude by registering your new benchmark compilation using its default source set name.
40
+
Register your new benchmark compilation using its default source set name.
41
41
Inthis instance, `jvmBenchmark` is the name of the default source set of the `benchmark` compilation.
42
42
43
43
```kotlin
@@ -49,6 +49,13 @@ Follow these steps to set up a separate compilation for benchmarks:
49
49
}
50
50
```
51
51
52
+
3. **AddBenchmarks**
53
+
54
+
Place your benchmark code into the default source set of the benchmark compilation.
55
+
The default source set can also depend on other source sets with benchmarks.
56
+
This way you can share benchmarks between multiple benchmark compilations.
57
+
Refer to our [writing benchmarks guide](docs/writing-benchmarks.md) for a comprehensive guide on writing benchmarks.
58
+
52
59
For additional information, refer to the [Kotlin documentation on creating a custom compilation](https://kotlinlang.org/docs/multiplatform-configure-compilations.html#create-a-custom-compilation).
53
60
and the [documentation on associating compiler tasks](https://kotlinlang.org/docs/gradle-configure-project.html#associate-compiler-tasks).
54
61
[Hereis a sample KotlinMultiplatform project](/examples/kotlin-multiplatform) with a separate compilation for benchmarks.
@@ -85,7 +92,7 @@ Set up a separate benchmark source set by following these simple steps:
85
92
86
93
3. **Register Benchmark Source Set**
87
94
88
-
Finally, register your benchmark source set. This informs the kotlinx-benchmark tool
95
+
Register your benchmark source set. This informs the kotlinx-benchmark tool
89
96
that benchmarks reside within this source set and need to be executed accordingly.
90
97
91
98
```kotlin
@@ -97,4 +104,9 @@ Set up a separate benchmark source set by following these simple steps:
97
104
}
98
105
```
99
106
107
+
4. **Add Benchmarks**
108
+
109
+
Place your benchmark code into the benchmark source set.
110
+
Refer to our [writing benchmarks guide](docs/writing-benchmarks.md) for a comprehensive guide on writing benchmarks.
111
+
100
112
[Here is a sample Kotlin/JVM project](/examples/kotlin) with custom source set for benchmarks.
0 commit comments