...

Text file src/github.com/google/flatbuffers/kotlin/benchmark/build.gradle.kts

Documentation: github.com/google/flatbuffers/kotlin/benchmark

     1import org.jetbrains.kotlin.ir.backend.js.compile
     2
     3plugins {
     4  kotlin("multiplatform")
     5  id("org.jetbrains.kotlinx.benchmark")
     6  id("io.morethan.jmhreport")
     7  id("de.undercouch.download")
     8}
     9
    10group = "com.google.flatbuffers.jmh"
    11version = "2.0.0-SNAPSHOT"
    12
    13// This plugin generates a static html page with the aggregation
    14// of all benchmarks ran. very useful visualization tool.
    15jmhReport {
    16  val baseFolder = project.file("build/reports/benchmarks/main").absolutePath
    17  val lastFolder = project.file(baseFolder).list()?.sortedArray()?.lastOrNull() ?: ""
    18  jmhResultPath = "$baseFolder/$lastFolder/jvm.json"
    19  jmhReportOutput = "$baseFolder/$lastFolder"
    20}
    21
    22// For now we benchmark on JVM only
    23benchmark {
    24  configurations {
    25    this.getByName("main") {
    26      iterations = 5
    27      iterationTime = 300
    28      iterationTimeUnit = "ms"
    29      // uncomment for benchmarking JSON op only
    30      include(".*JsonBenchmark.*")
    31    }
    32  }
    33  targets {
    34    register("jvm")
    35  }
    36}
    37
    38kotlin {
    39  jvm()
    40
    41  sourceSets {
    42
    43    all {
    44      languageSettings.enableLanguageFeature("InlineClasses")
    45    }
    46
    47    val jvmMain by getting {
    48      dependencies {
    49        implementation(kotlin("stdlib-common"))
    50        implementation(project(":flatbuffers-kotlin"))
    51        implementation(libs.kotlinx.benchmark.runtime)
    52        implementation("com.google.flatbuffers:flatbuffers-java:2.0.3")
    53        // json serializers
    54        implementation(libs.moshi.kotlin)
    55        implementation(libs.gson)
    56      }
    57    }
    58  }
    59}
    60
    61// This task download all JSON files used for benchmarking
    62tasks.register<de.undercouch.gradle.tasks.download.Download>("downloadMultipleFiles") {
    63  // We are downloading json benchmark samples from serdes-rs project.
    64  // see: https://github.com/serde-rs/json-benchmark/blob/master/data
    65  val baseUrl = "https://github.com/serde-rs/json-benchmark/raw/master/data/"
    66  src(listOf("$baseUrl/canada.json", "$baseUrl/twitter.json", "$baseUrl/citm_catalog.json"))
    67  dest(File("${project.projectDir.absolutePath}/src/jvmMain/resources"))
    68  overwrite(false)
    69}

View as plain text