Refactor benchmark report writer

This commit is contained in:
Iaroslav Postovalov 2021-06-19 20:52:26 +07:00
parent 65d0cbbe31
commit 7feb87ff05
4 changed files with 47 additions and 53 deletions

View File

@ -10,9 +10,7 @@ allprojects {
maven("http://logicrunch.research.it.uu.se/maven") {
isAllowInsecureProtocol = true
}
maven("https://oss.sonatype.org/content/repositories/snapshots") {
}
maven("https://oss.sonatype.org/content/repositories/snapshots")
mavenCentral()
}

View File

@ -4,13 +4,14 @@ plugins {
}
repositories {
gradlePluginPortal()
maven("https://repo.kotlin.link")
mavenCentral()
gradlePluginPortal()
}
dependencies {
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0")
api("ru.mipt.npm:gradle-tools:0.9.10")
api("ru.mipt.npm:gradle-tools:0.10.0")
api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.3.1")
}

View File

@ -5,8 +5,11 @@
package space.kscience.kmath.benchmarks
import kotlinx.benchmark.gradle.BenchmarksExtension
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import org.gradle.api.Project
import ru.mipt.npm.gradle.KScienceReadmeExtension
import java.time.*
import java.time.format.*
import java.time.temporal.ChronoField.*
@ -42,15 +45,9 @@ private fun noun(number: Number, singular: String, plural: String) = if (number.
fun Project.addBenchmarkProperties() {
val benchmarksProject = this
rootProject.subprojects.forEach { p ->
p.extensions.findByType(ru.mipt.npm.gradle.KScienceReadmeExtension::class.java)?.run {
benchmarksProject.extensions.findByType(kotlinx.benchmark.gradle.BenchmarksExtension::class.java)?.configurations?.forEach { cfg ->
// TODO remove this hack when https://github.com/mipt-npm/gradle-tools/pull/15 is merged
@Suppress("UNCHECKED_CAST")
(javaClass.getDeclaredField("properties")
.also {
it.isAccessible = true
}[this] as MutableMap<String, () -> Any?>)["benchmark${cfg.name.replaceFirstChar(Char::uppercase)}"] =
{
p.extensions.findByType(KScienceReadmeExtension::class.java)?.run {
benchmarksProject.extensions.findByType(BenchmarksExtension::class.java)?.configurations?.forEach { cfg ->
property("benchmark${cfg.name.replaceFirstChar(Char::uppercase)}") {
val launches = benchmarksProject.buildDir.resolve("reports/benchmarks/${cfg.name}")
val resDirectory = launches.listFiles()?.maxByOrNull {
@ -61,9 +58,7 @@ fun Project.addBenchmarkProperties() {
"> **Can't find appropriate benchmark data. Try generating readme files after running benchmarks**."
} else {
val reports =
kotlinx.serialization.json.Json.decodeFromString<List<JmhReport>>(
resDirectory.resolve("jvm.json").readText()
)
Json.decodeFromString<List<JmhReport>>(resDirectory.resolve("jvm.json").readText())
buildString {
appendLine("<details>")

View File

@ -5,7 +5,7 @@ pluginManagement {
gradlePluginPortal()
}
val toolsVersion = "0.9.10"
val toolsVersion = "0.10.0"
val kotlinVersion = "1.5.0"
plugins {