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
|
package com.github.michaelbull.result
|
||||||
|
|
||||||
import org.openjdk.jmh.annotations.Benchmark
|
import kotlinx.benchmark.BenchmarkMode
|
||||||
import org.openjdk.jmh.annotations.BenchmarkMode
|
import kotlinx.benchmark.Mode
|
||||||
import org.openjdk.jmh.annotations.Mode
|
import kotlinx.benchmark.OutputTimeUnit
|
||||||
import org.openjdk.jmh.annotations.OutputTimeUnit
|
import kotlinx.benchmark.BenchmarkTimeUnit
|
||||||
import org.openjdk.jmh.annotations.Scope
|
import kotlinx.benchmark.Benchmark
|
||||||
import org.openjdk.jmh.annotations.State
|
import kotlinx.benchmark.Blackhole
|
||||||
import org.openjdk.jmh.infra.Blackhole
|
import kotlinx.benchmark.State
|
||||||
import java.util.concurrent.TimeUnit
|
import kotlinx.benchmark.Scope
|
||||||
|
|
||||||
|
@State(Scope.Benchmark)
|
||||||
@BenchmarkMode(Mode.Throughput)
|
@BenchmarkMode(Mode.Throughput)
|
||||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
@OutputTimeUnit(BenchmarkTimeUnit.MILLISECONDS)
|
||||||
class BindingBenchmark {
|
class BindingBenchmark {
|
||||||
|
|
||||||
private object Error
|
private object Error
|
||||||
@ -59,7 +60,6 @@ class BindingBenchmark {
|
|||||||
blackhole.consume(result)
|
blackhole.consume(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@State(Scope.Thread)
|
|
||||||
private companion object {
|
private companion object {
|
||||||
private fun provideX(): Result<Int, Error> = Ok(1)
|
private fun provideX(): Result<Int, Error> = Ok(1)
|
||||||
private fun provideY(): Result<Int, Error> = Ok(2)
|
private fun provideY(): Result<Int, Error> = Ok(2)
|
@ -3,27 +3,10 @@ description = "A Result monad for modelling success or failure operations."
|
|||||||
plugins {
|
plugins {
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
kotlin("multiplatform")
|
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 {
|
kotlin {
|
||||||
jvm {
|
jvm {
|
||||||
withJava()
|
|
||||||
|
|
||||||
compilations.all {
|
compilations.all {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
@ -45,8 +28,6 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val jvmMain by getting
|
|
||||||
|
|
||||||
val jvmTest by getting {
|
val jvmTest by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("test-junit"))
|
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 {
|
val jsTest by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("test-js"))
|
implementation(kotlin("test-js"))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
rootProject.name = "kotlin-result"
|
rootProject.name = "kotlin-result"
|
||||||
|
|
||||||
include(
|
include(
|
||||||
|
"benchmarks",
|
||||||
"example",
|
"example",
|
||||||
"kotlin-result",
|
"kotlin-result",
|
||||||
"kotlin-result-coroutines"
|
"kotlin-result-coroutines"
|
||||||
|
Loading…
Reference in New Issue
Block a user