Move benchmarks to separate subproject
This commit is contained in:
parent
d9662cc8e7
commit
0df4c62d4f
@ -0,0 +1,43 @@
|
||||
description = "Benchmarks for kotlin-result."
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
id("kotlinx.benchmark")
|
||||
id("org.jetbrains.kotlin.plugin.allopen")
|
||||
}
|
||||
|
||||
allOpen {
|
||||
annotation("org.openjdk.jmh.annotations.State")
|
||||
annotation("org.openjdk.jmh.annotations.BenchmarkMode")
|
||||
}
|
||||
|
||||
benchmark {
|
||||
targets {
|
||||
register("jvm")
|
||||
// TODO: enable js benchmarking once https://github.com/Kotlin/kotlinx-benchmark/issues/28 is fixed.
|
||||
// register("js")
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
js {
|
||||
nodejs()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(project(":kotlin-result"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx.benchmark.runtime:${Versions.kotlinBenchmark}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,17 @@
|
||||
package com.github.michaelbull.result
|
||||
|
||||
import org.openjdk.jmh.annotations.Benchmark
|
||||
import org.openjdk.jmh.annotations.BenchmarkMode
|
||||
import org.openjdk.jmh.annotations.Mode
|
||||
import org.openjdk.jmh.annotations.OutputTimeUnit
|
||||
import org.openjdk.jmh.annotations.Scope
|
||||
import org.openjdk.jmh.annotations.State
|
||||
import org.openjdk.jmh.infra.Blackhole
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlinx.benchmark.BenchmarkMode
|
||||
import kotlinx.benchmark.Mode
|
||||
import kotlinx.benchmark.OutputTimeUnit
|
||||
import kotlinx.benchmark.BenchmarkTimeUnit
|
||||
import kotlinx.benchmark.Benchmark
|
||||
import kotlinx.benchmark.Blackhole
|
||||
import kotlinx.benchmark.State
|
||||
import kotlinx.benchmark.Scope
|
||||
|
||||
@State(Scope.Benchmark)
|
||||
@BenchmarkMode(Mode.Throughput)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@OutputTimeUnit(BenchmarkTimeUnit.MILLISECONDS)
|
||||
class BindingBenchmark {
|
||||
|
||||
private object Error
|
||||
@ -59,7 +60,6 @@ class BindingBenchmark {
|
||||
blackhole.consume(result)
|
||||
}
|
||||
|
||||
@State(Scope.Thread)
|
||||
private companion object {
|
||||
private fun provideX(): Result<Int, Error> = Ok(1)
|
||||
private fun provideY(): Result<Int, Error> = Ok(2)
|
@ -3,27 +3,10 @@ description = "A Result monad for modelling success or failure operations."
|
||||
plugins {
|
||||
`maven-publish`
|
||||
kotlin("multiplatform")
|
||||
id("org.jetbrains.kotlin.plugin.allopen")
|
||||
id("kotlinx.benchmark")
|
||||
}
|
||||
|
||||
allOpen {
|
||||
annotation("org.openjdk.jmh.annotations.State")
|
||||
annotation("org.openjdk.jmh.annotations.BenchmarkMode")
|
||||
}
|
||||
|
||||
sourceSets.create("benchmark")
|
||||
|
||||
benchmark {
|
||||
targets {
|
||||
register("jvmBenchmark")
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
withJava()
|
||||
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
@ -45,8 +28,6 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
val jvmMain by getting
|
||||
|
||||
val jvmTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-junit"))
|
||||
@ -54,15 +35,6 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
val jvmBenchmark by getting {
|
||||
dependsOn(jvmMain)
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx.benchmark.runtime:${Versions.kotlinBenchmark}")
|
||||
}
|
||||
}
|
||||
|
||||
val jsMain by getting
|
||||
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
|
@ -1,6 +1,7 @@
|
||||
rootProject.name = "kotlin-result"
|
||||
|
||||
include(
|
||||
"benchmarks",
|
||||
"example",
|
||||
"kotlin-result",
|
||||
"kotlin-result-coroutines"
|
||||
|
Loading…
Reference in New Issue
Block a user