Skip to content

Commit a39e5a2

Browse files
committed
Fix compatibility with 1.3.40-eap-105
1 parent 85034b1 commit a39e5a2

File tree

16 files changed

+164
-233
lines changed

16 files changed

+164
-233
lines changed

README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
[![JetBrains incubator project](https://jb.gg/badges/incubator.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
22
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)
3+
[![Download](https://api.bintray.com/packages/kotlin/kotlinx/kotlinx.benchmark/images/download.svg) ](https://bintray.com/kotlin/kotlinx/kotlinx.benchmark/_latestVersion)
34

4-
`kotlinx.benchmark` is a toolkit for running benchmarks for code written in Kotlin
5+
**kotlinx.benchmark** is a toolkit for running benchmarks for multiplatform code written in Kotlin
56
and running on all supported targets: JVM, JavaScript and Native.
67

78
If you're familiar with [JMH](https://openjdk.java.net/projects/code-tools/jmh/), it is very similar and uses it under
89
the hoods to run benchmarks on JVM.
910

11+
# Requirements
12+
13+
Gradle 5.1 or newer
14+
Kotlin 1.3.40 or newer
15+
1016
# Gradle plugin
1117

1218
Add repository in `settings.gradle` to enable bintray repository for plugin lookup
@@ -20,31 +26,22 @@ pluginManagement {
2026
}
2127
```
2228

23-
TODO: This is not needed in latest Gradle versions.
24-
If you are using it for Kotlin Multiplatform, enable metadata in `settings.gradle`:
29+
For Kotlin/JS specify building `nodejs` flavour:
2530

2631
```groovy
27-
enableFeaturePreview('GRADLE_METADATA')
28-
```
29-
30-
TODO: Migrate to 1.3.40 node.js integrated support.
31-
For Kotlin/JS code, add Node plugin as well:
32-
33-
```groovy
34-
plugins {
35-
id 'kotlinx.team.node'
36-
}
37-
38-
node {
39-
version = "$node_version"
32+
kotlin {
33+
js {
34+
nodejs()
35+
36+
}
4037
}
4138
```
4239

4340
For Kotlin/JVM code, add `allopen` plugin to make JMH happy. Alternatively, make all benchmark classes and methods `open`.
4441

4542
```groovy
4643
plugins {
47-
id 'org.jetbrains.kotlin.plugin.allopen' version "1.3.31"
44+
id 'org.jetbrains.kotlin.plugin.allopen'
4845
}
4946
5047
allOpen {
@@ -82,7 +79,7 @@ benchmark {
8279
}
8380
```
8481

85-
Example for plain Java project:
82+
This package can also be used for Java and Kotlin/JVM projects. Register a Java sourceSet as a target:
8683

8784
```groovy
8885
benchmark {

examples/kotlin-kts/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.jetbrains.kotlin.gradle.tasks.*
77
plugins {
88
java
99
kotlin("jvm")
10-
kotlin("plugin.allopen") version "1.3.40-eap-104"
10+
kotlin("plugin.allopen") version "1.3.40-eap-105"
1111
id("kotlinx.benchmark") version "0.2.0"
1212
}
1313

examples/kotlin-multiplatform/build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66

77
plugins {
88
id 'org.jetbrains.kotlin.multiplatform'
9-
id 'org.jetbrains.kotlin.plugin.allopen' version "1.3.40-eap-104"
9+
id 'org.jetbrains.kotlin.plugin.allopen' version "1.3.40-eap-105"
1010
id 'kotlinx.benchmark' version "0.2.0"
1111
id 'kotlinx.team.node'
1212
}
@@ -17,13 +17,11 @@ allOpen {
1717
}
1818

1919
kotlin {
20-
/*
2120
infra {
2221
target('macosX64')
2322
target('linuxX64')
2423
target('mingwX64')
2524
}
26-
*/
2725

2826
jvm {
2927
compilations.all {

examples/kotlin/benchmarks/src/TestBenchmark.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package test
22

33
import org.openjdk.jmh.annotations.*
44
import java.util.concurrent.*
5+
import kotlin.math.*
56

67
@State(Scope.Benchmark)
78
@Fork(1)
@@ -17,11 +18,11 @@ class TestBenchmark {
1718

1819
@Benchmark
1920
fun sqrtBenchmark(): Double {
20-
return Math.sqrt(data.value)
21+
return sqrt(data.value)
2122
}
2223

2324
@Benchmark
2425
fun cosBenchmark(): Double {
25-
return Math.cos(data.value)
26+
return cos(data.value)
2627
}
2728
}

examples/kotlin/build.gradle

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
plugins {
22
id 'java'
33
id 'org.jetbrains.kotlin.jvm'
4-
id 'org.jetbrains.kotlin.plugin.allopen' version "1.3.40-eap-104"
4+
id 'org.jetbrains.kotlin.plugin.allopen' version "1.3.40-eap-105"
55
id 'kotlinx.benchmark' version '0.2.0'
66
}
77

8-
apply from: rootProject.file('gradle/shared.gradle')
98

109
// how to apply plugin to a specific source set?
1110
allOpen {
@@ -17,9 +16,24 @@ sourceSets {
1716
benchmarks
1817
}
1918

19+
sourceSets.all {
20+
kotlin.srcDirs = ["$it.name/src"]
21+
java.srcDirs = ["$it.name/src"]
22+
resources.srcDirs = ["$it.name/resources"]
23+
}
24+
25+
compileKotlin {
26+
kotlinOptions.jvmTarget = "1.8"
27+
}
28+
compileTestKotlin {
29+
kotlinOptions.jvmTarget = "1.8"
30+
}
31+
32+
2033
// Propagate dependencies from main sourceSet
2134
// You can add "+ sourceSets.test.output" to include test output as well
2235
dependencies {
36+
api group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk8', version: kotlin_version
2337
implementation(project(":kotlinx.benchmark.runtime"))
2438
benchmarksCompile sourceSets.main.output + sourceSets.main.runtimeClasspath
2539
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ group = org.jetbrains.kotlinx
33
version = 0.2.0
44

55
kotlin.code.style=official
6-
kotlin_version=1.3.40-eap-104
6+
kotlin_version=1.3.40-eap-105
77
jmhVersion=1.21
88
junit_version=4.12
99

gradle/pom.gradle

Lines changed: 0 additions & 32 deletions
This file was deleted.

gradle/publish.gradle

Lines changed: 0 additions & 136 deletions
This file was deleted.

gradle/utility.gradle

Lines changed: 0 additions & 22 deletions
This file was deleted.

plugin/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ buildscript {
1313

1414
plugins {
1515
id 'java-gradle-plugin'
16-
id 'org.jetbrains.kotlin.jvm' version "1.3.40-eap-104"
16+
id 'org.jetbrains.kotlin.jvm' version "1.3.40-eap-105"
1717
}
1818

1919
apply plugin: 'kotlinx.team.infra'
@@ -76,9 +76,7 @@ dependencies {
7676
compile group: 'org.jetbrains.kotlin', name: 'kotlin-native-library-reader', version: kotlin_version, {
7777
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-compiler'
7878
}
79-
80-
compileOnly "kotlinx.team:kotlinx.team.infra:$infra_version"
81-
79+
8280
compileOnly group: 'org.jetbrains.kotlin.multiplatform', name: 'org.jetbrains.kotlin.multiplatform.gradle.plugin', version: kotlin_version
8381
compileOnly "org.openjdk.jmh:jmh-generator-bytecode:$jmhVersion" // used in worker
8482

0 commit comments

Comments
 (0)