Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 3 | */ |
Vsevolod Tolstopyatov | c42d338 | 2019-04-30 15:18:36 +0300 | [diff] [blame] | 4 | sourceCompatibility = 1.8 |
| 5 | targetCompatibility = 1.8 |
Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame] | 6 | |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 7 | apply plugin: "net.ltgt.apt" |
| 8 | apply plugin: "com.github.johnrengelman.shadow" |
| 9 | apply plugin: "me.champeau.gradle.jmh" |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 10 | |
| 11 | repositories { |
Roman Elizarov | 63d1d1b | 2019-02-22 14:40:38 +0300 | [diff] [blame] | 12 | maven { url "https://repo.typesafe.com/typesafe/releases/" } |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 13 | } |
| 14 | |
Vsevolod Tolstopyatov | c42d338 | 2019-04-30 15:18:36 +0300 | [diff] [blame] | 15 | compileJmhKotlin { |
| 16 | kotlinOptions { |
| 17 | jvmTarget = "1.8" |
| 18 | freeCompilerArgs += ['-Xjvm-default=enable'] |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | /* |
| 23 | * Due to a bug in the inliner it sometimes does not remove inlined symbols (that are later renamed) from unused code paths, |
| 24 | * and it breaks JMH that tries to post-process these symbols and fails because they are renamed. |
| 25 | */ |
| 26 | task removeRedundantFiles(type: Delete) { |
| 27 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$buildHistoOnScore\$1\$\$special\$\$inlined\$filter\$1\$1.class" |
| 28 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$nBlanks\$1\$\$special\$\$inlined\$map\$1\$1.class" |
| 29 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$score2\$1\$\$special\$\$inlined\$map\$1\$1.class" |
| 30 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$bonusForDoubleLetter\$1\$\$special\$\$inlined\$map\$1\$1.class" |
| 31 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$nBlanks\$1\$\$special\$\$inlined\$map\$1\$2\$1.class" |
| 32 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$bonusForDoubleLetter\$1\$\$special\$\$inlined\$map\$1\$2\$1.class" |
| 33 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$score2\$1\$\$special\$\$inlined\$map\$1\$2\$1.class" |
| 34 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOptKt\$\$special\$\$inlined\$collect\$1\$1.class" |
| 35 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOptKt\$\$special\$\$inlined\$collect\$2\$1.class" |
| 36 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleOpt\$play\$histoOfLetters\$1\$\$special\$\$inlined\$fold\$1\$1.class" |
Vsevolod Tolstopyatov | c42d338 | 2019-04-30 15:18:36 +0300 | [diff] [blame] | 37 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleBase\$play\$buildHistoOnScore\$1\$\$special\$\$inlined\$filter\$1\$1.class" |
| 38 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble/FlowPlaysScrabbleBase\$play\$histoOfLetters\$1\$\$special\$\$inlined\$fold\$1\$1.class" |
Vsevolod Tolstopyatov | c42d338 | 2019-04-30 15:18:36 +0300 | [diff] [blame] | 39 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/scrabble//SaneFlowPlaysScrabble\$play\$buildHistoOnScore\$1\$\$special\$\$inlined\$filter\$1\$1.class" |
| 40 | |
Vsevolod Tolstopyatov | c438a0e | 2019-04-30 16:36:14 +0300 | [diff] [blame] | 41 | // Primes |
| 42 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/misc/Numbers\$\$special\$\$inlined\$filter\$1\$2\$1.class" |
| 43 | delete "$buildDir/classes/kotlin/jmh/benchmarks/flow/misc/Numbers\$\$special\$\$inlined\$filter\$1\$1.class" |
Vsevolod Tolstopyatov | c42d338 | 2019-04-30 15:18:36 +0300 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | jmhRunBytecodeGenerator.dependsOn(removeRedundantFiles) |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 47 | |
Nikita Koval | 74b250f | 2019-03-19 13:24:07 +0300 | [diff] [blame] | 48 | // It is better to use the following to run benchmarks, otherwise you may get unexpected errors: |
Vsevolod Tolstopyatov | c42d338 | 2019-04-30 15:18:36 +0300 | [diff] [blame] | 49 | // ./gradlew --no-daemon cleanJmhJar jmh -Pjmh="MyBenchmark" |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 50 | jmh { |
Vsevolod Tolstopyatov | c42d338 | 2019-04-30 15:18:36 +0300 | [diff] [blame] | 51 | jmhVersion = '1.21' |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 52 | duplicateClassesStrategy DuplicatesStrategy.INCLUDE |
Nikita Koval | 74b250f | 2019-03-19 13:24:07 +0300 | [diff] [blame] | 53 | failOnError = true |
| 54 | resultFormat = 'CSV' |
Vsevolod Tolstopyatov | c42d338 | 2019-04-30 15:18:36 +0300 | [diff] [blame] | 55 | if (project.hasProperty('jmh')) { |
| 56 | include = ".*" + project.jmh + ".*" |
| 57 | } |
| 58 | // includeTests = false |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 59 | } |
| 60 | |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 61 | jmhJar { |
| 62 | baseName 'benchmarks' |
| 63 | classifier = null |
| 64 | version = null |
Vsevolod Tolstopyatov | f284dfc | 2018-09-20 12:00:31 +0300 | [diff] [blame] | 65 | destinationDir = file("$rootDir") |
Kirill Timofeev | a518696 | 2017-10-25 14:25:47 +0300 | [diff] [blame] | 66 | } |
| 67 | |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 68 | dependencies { |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 69 | compile "org.openjdk.jmh:jmh-core:1.21" |
Vsevolod Tolstopyatov | c42d338 | 2019-04-30 15:18:36 +0300 | [diff] [blame] | 70 | compile "io.projectreactor:reactor-core:$reactor_vesion" |
| 71 | compile 'io.reactivex.rxjava2:rxjava:2.1.9' |
| 72 | compile "com.github.akarnokd:rxjava2-extensions:0.20.8" |
| 73 | |
| 74 | compile "org.openjdk.jmh:jmh-core:1.21" |
Vsevolod Tolstopyatov | e50a0fa | 2019-01-28 11:34:24 +0300 | [diff] [blame] | 75 | compile 'com.typesafe.akka:akka-actor_2.12:2.5.0' |
| 76 | compile project(':kotlinx-coroutines-core') |
Vsevolod Tolstopyatov | 305c66a | 2018-08-21 21:01:58 +0300 | [diff] [blame] | 77 | } |