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