blob: 147fe82d68d0f1fca4655ffca6c27d0085b83176 [file] [edit]
import kotlinx.benchmark.gradle.JmhBytecodeGeneratorTask
import kotlinx.benchmark.gradle.benchmark
plugins {
id("common-configuration")
id("com.autonomousapps.dependency-analysis")
kotlin("jvm")
alias(libs.plugins.kotlinx.benchmark)
id("java-test-fixtures")
}
dependencies {
testImplementation(kotlinStdlib())
testImplementation(testFixtures(project(":compiler:tests-common")))
testImplementation(project(":compiler:cli"))
testImplementation(intellijCore())
testImplementation(libs.kotlinx.benchmark.runtime)
testFixturesApi(platform(libs.junit.bom))
testFixturesApi(libs.junit.jupiter.api)
testFixturesApi(libs.junit.platform.launcher)
testRuntimeOnly(libs.junit.jupiter.engine)
testFixturesApi(testFixtures(project(":compiler:tests-integration")))
}
sourceSets {
"main" { none() }
"test" { projectDefault() }
}
optInToK1Deprecation()
val warmupsParam = providers.gradleProperty("warmups").orNull
val iterationsParam = providers.gradleProperty("iterations").orNull
val includePattern = providers.gradleProperty("include").orNull
val sizeParam = providers.gradleProperty("size").orNull
benchmark {
configurations {
named("main") {
iterationTime = 1 // Required param
iterationTimeUnit = "sec" // Required param
warmups = warmupsParam?.toInt() ?: 5 // `5` is currently default in JMH
iterations = iterationsParam?.toInt() ?: 5 // `5` is currently default in JMH
include(includePattern ?: "*") // Benchmark everything if the pattern isn't specified
if (sizeParam != null) {
// Use size from annotation arguments if the param isn't specified
// CAUTION: large size might cause long execution time
param("size", sizeParam.toInt())
}
}
}
targets {
register("test")
}
}
tasks.withType<JavaExec>().matching { it.name == "testBenchmark" }.configureEach {
val ideaHomeForTests = this.project.configurations.detachedConfiguration(this.project.dependencies.project(":", configuration = "ideaHomeForTests"))
jvmArgumentProviders.add(this.project.objects.newInstance(SystemPropertyClasspathDirectoryProvider::class.java).apply {
property.set("idea.home.path")
classpath.from(ideaHomeForTests)
directory.value(ideaHomePathForTests())
})
systemProperty("idea.use.native.fs.for.win", false)
}
tasks.withType<JmhBytecodeGeneratorTask>().configureEach {
outputs.cacheIf("Disabled because of https://github.com/Kotlin/kotlinx-benchmark/issues/364 (remove after version upgrading)") {
false
}
}
projectTests {
testTask {
workingDir = rootDir
}
withJvmStdlibAndReflect()
}