Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 1 | /* |
Aurimas Liutikas | 79e555e | 2021-05-17 17:41:41 +0000 | [diff] [blame] | 2 | * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 3 | */ |
| 4 | |
Victor Turansky | 964cd92 | 2020-05-02 19:52:56 +0300 | [diff] [blame] | 5 | @file:Suppress("UnstableApiUsage") |
| 6 | |
Victor Turansky | 4511c23 | 2020-05-15 12:00:36 +0300 | [diff] [blame] | 7 | import me.champeau.gradle.* |
| 8 | import org.jetbrains.kotlin.gradle.tasks.* |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 9 | |
| 10 | plugins { |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 11 | id("com.github.johnrengelman.shadow") |
Victor Turansky | 4511c23 | 2020-05-15 12:00:36 +0300 | [diff] [blame] | 12 | id("me.champeau.gradle.jmh") apply false |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | repositories { |
| 16 | maven("https://repo.typesafe.com/typesafe/releases/") |
| 17 | } |
| 18 | |
Victor Turansky | 4511c23 | 2020-05-15 12:00:36 +0300 | [diff] [blame] | 19 | java { |
| 20 | sourceCompatibility = JavaVersion.VERSION_1_8 |
| 21 | targetCompatibility = JavaVersion.VERSION_1_8 |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 22 | } |
| 23 | |
Victor Turansky | 4511c23 | 2020-05-15 12:00:36 +0300 | [diff] [blame] | 24 | apply(plugin="me.champeau.gradle.jmh") |
| 25 | |
| 26 | tasks.named<KotlinCompile>("compileJmhKotlin") { |
| 27 | kotlinOptions { |
| 28 | jvmTarget = "1.8" |
| 29 | freeCompilerArgs += "-Xjvm-default=enable" |
| 30 | } |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 31 | } |
| 32 | |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 33 | // It is better to use the following to run benchmarks, otherwise you may get unexpected errors: |
| 34 | // ./gradlew --no-daemon cleanJmhJar jmh -Pjmh="MyBenchmark" |
Victor Turansky | 4511c23 | 2020-05-15 12:00:36 +0300 | [diff] [blame] | 35 | extensions.configure<JMHPluginExtension>("jmh") { |
Vsevolod Tolstopyatov | 9587590 | 2020-10-20 02:40:38 -0700 | [diff] [blame] | 36 | jmhVersion = "1.26" |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 37 | duplicateClassesStrategy = DuplicatesStrategy.INCLUDE |
| 38 | failOnError = true |
| 39 | resultFormat = "CSV" |
| 40 | project.findProperty("jmh")?.also { |
| 41 | include = listOf(".*$it.*") |
| 42 | } |
| 43 | // includeTests = false |
| 44 | } |
| 45 | |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 46 | val jmhJarTask = tasks.named<Jar>("jmhJar") { |
Victor Turansky | 964cd92 | 2020-05-02 19:52:56 +0300 | [diff] [blame] | 47 | archiveBaseName by "benchmarks" |
| 48 | archiveClassifier by null |
| 49 | archiveVersion by null |
| 50 | destinationDirectory.file("$rootDir") |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 51 | } |
| 52 | |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 53 | tasks { |
| 54 | // For some reason the DuplicatesStrategy from jmh is not enough |
| 55 | // and errors with duplicates appear unless I force it to WARN only: |
| 56 | withType<Copy> { |
| 57 | duplicatesStrategy = DuplicatesStrategy.WARN |
| 58 | } |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 59 | |
Steve Elliott | ca095be | 2022-07-25 14:26:10 +0000 | [diff] [blame] | 60 | build { |
| 61 | dependsOn(jmhJarTask) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | dependencies { |
| 66 | implementation("org.openjdk.jmh:jmh-core:1.26") |
| 67 | implementation("io.projectreactor:reactor-core:${version("reactor")}") |
| 68 | implementation("io.reactivex.rxjava2:rxjava:2.1.9") |
| 69 | implementation("com.github.akarnokd:rxjava2-extensions:0.20.8") |
| 70 | |
| 71 | implementation("com.typesafe.akka:akka-actor_2.12:2.5.0") |
| 72 | implementation(project(":kotlinx-coroutines-core")) |
| 73 | implementation(project(":kotlinx-coroutines-reactive")) |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 74 | |
| 75 | // add jmh dependency on main |
Victor Turansky | 4511c23 | 2020-05-15 12:00:36 +0300 | [diff] [blame] | 76 | "jmhImplementation"(sourceSets.main.get().runtimeClasspath) |
Vsevolod Tolstopyatov | 0f15812 | 2020-04-29 23:35:41 +0300 | [diff] [blame] | 77 | } |