File tree Expand file tree Collapse file tree 4 files changed +17
-6
lines changed
benchmarks/src/jvmMain/kotlin
gradle/build-logic/common-plugins/src/main/kotlin Expand file tree Collapse file tree 4 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 1
1
package bench
2
2
3
- import java.util.concurrent.*
3
+ import java.util.concurrent.TimeUnit
4
+ import jdk.incubator.vector.LongVector
4
5
import org.openjdk.jmh.annotations.*
5
6
6
7
const val WARMUP_ITERATIONS = 20
7
8
8
9
@State(Scope .Benchmark )
9
- @Fork(1 )
10
10
@BenchmarkMode(Mode .AverageTime )
11
11
@OutputTimeUnit(TimeUnit .NANOSECONDS )
12
12
@Warmup(iterations = WARMUP_ITERATIONS , time = 1 , timeUnit = TimeUnit .SECONDS )
13
13
@Measurement(iterations = 1 , time = 1 , timeUnit = TimeUnit .SECONDS )
14
+ @Fork(value = 1 , jvmArgsAppend = [" --add-modules=jdk.incubator.vector" ])
14
15
class JvmTestBenchmark {
16
+
15
17
private var data = 0.0
16
18
17
19
@Setup
@@ -28,4 +30,6 @@ class JvmTestBenchmark {
28
30
fun cosBenchmark (): Double {
29
31
return Math .cos(data)
30
32
}
33
+
34
+ @Benchmark fun vectorAPI () = LongVector .SPECIES_PREFERRED .length()
31
35
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
16
16
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
17
17
import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask
18
18
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
19
+ import org.jetbrains.kotlin.gradle.testing.internal.KotlinTestReport
19
20
import java.nio.file.Path
20
21
21
22
/* * Java version properties. */
@@ -188,6 +189,10 @@ fun KotlinJvmTest.configureKotlinTest() {
188
189
configureJavaTest()
189
190
}
190
191
192
+ context(Project )
193
+ fun KotlinTestReport.configureTestReport () {
194
+ }
195
+
191
196
context(Project )
192
197
fun Test.configureJavaTest () {
193
198
useJUnitPlatform()
Original file line number Diff line number Diff line change 1
1
package plugins
2
2
3
3
import common.libs
4
- import kotlinx.benchmark.gradle.BenchmarkTarget
5
- import kotlinx.benchmark.gradle.JvmBenchmarkTarget
6
- import kotlinx.benchmark.gradle.benchmark
4
+ import kotlinx.benchmark.gradle.*
7
5
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
8
6
9
7
/* *
@@ -36,7 +34,7 @@ benchmark {
36
34
iterations = 5 // number of iterations
37
35
iterationTime = 3 // time in seconds per iteration
38
36
iterationTimeUnit = " ms"
39
- advanced(" jvmForks" , 3 )
37
+ advanced(" jvmForks" , " definedByJmh " )
40
38
advanced(" jsUseBridge" , true )
41
39
}
42
40
}
@@ -48,6 +46,8 @@ kotlin.sourceSets.named("commonMain") {
48
46
dependencies { implementation(libs.kotlinx.bench.runtime) }
49
47
}
50
48
49
+ tasks { withType(JmhBytecodeGeneratorTask ::class ) {} }
50
+
51
51
fun BenchmarkTarget.configureJmh () {
52
52
this as JvmBenchmarkTarget
53
53
jmhVersion = libs.versions.jmh.get()
Original file line number Diff line number Diff line change @@ -83,6 +83,8 @@ kotlinMultiplatform.apply {
83
83
84
84
// distribution { outputDirectory = file("$projectDir/docs") }
85
85
}
86
+
87
+ testRuns.configureEach { executionTask.configure { configureTestReport() } }
86
88
}
87
89
88
90
// Disable wasm by default as some of the common dependencies are not compatible with wasm.
You can’t perform that action at this time.
0 commit comments