Add JMH for benchmark

This commit is contained in:
Ivan Cilcic
2019-05-31 22:12:48 +03:00
committed by Mikhail Glukhikh
parent 0e8bbab925
commit c47a8e2025
10 changed files with 247 additions and 134 deletions
+62
View File
@@ -4,6 +4,7 @@ plugins {
}
group = "org.jetbrains.kotlin.fir"
val jmhVersion = "1.21"
repositories {
mavenCentral()
@@ -20,6 +21,10 @@ dependencies {
compile("junit", "junit", "4.4")
compile(projectTests(":compiler:fir:psi2fir"))
compile("org.openjdk.jmh", "jmh-core", jmhVersion)
compile("org.openjdk.jmh", "jmh-generator-bytecode", jmhVersion)
compile("org.openjdk.jmh", "jmh-generator-annprocess", jmhVersion)
}
sourceSets {
@@ -30,3 +35,60 @@ sourceSets {
projectTest {
workingDir = rootDir
}
val compactClasspath by tasks.creating(Jar::class) {
archiveAppendix.set("classpath")
inputs.files(sourceSets["main"].runtimeClasspath + sourceSets["test"].runtimeClasspath)
doFirst {
manifest {
attributes["Class-Path"] = (sourceSets["main"].runtimeClasspath + sourceSets["test"].runtimeClasspath).files
.joinToString(separator = " ", transform = { it.toURI().toURL().toString() })
}
}
}
val jmhBytecode by tasks.creating(JavaExec::class) {
tasks["classes"].mustRunAfter(tasks["clean"])
tasks["compactClasspath"].mustRunAfter(tasks["classes"])
dependsOn(tasks["clean"])
dependsOn(tasks["classes"])
dependsOn(tasks["compactClasspath"])
classpath = files(tasks["compactClasspath"].outputs.files.singleFile.absolutePath)
main = "org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator"
args(
"${project.buildDir}/classes/kotlin/test", "${project.buildDir}/generated-sources/jmh/",
"${project.buildDir}/classes/kotlin/test", "default"
)
}
tasks {
compileTestJava {
source(fileTree("${project.buildDir}/generated-sources/jmh/"))
destinationDir = file("${project.buildDir}/generated-classes/jmh/")
}
}
val jmhCompile by tasks.creating(JavaCompile::class) {
/*classpath = sourceSets["test"].runtimeClasspath + files("${project.buildDir}/generated-sources/jmh/")
source(fileTree("${project.buildDir}/generated-sources/jmh/"))
destinationDir = file("${project.buildDir}/generated-classes/jmh/")*/
}
val jmhExec by tasks.creating(JavaExec::class) {
dependsOn(tasks["compileTestJava"])
doFirst {
classpath = files(
tasks["compactClasspath"].outputs.files.singleFile.absolutePath,
"${project.buildDir}/generated-classes/jmh/",
"${project.buildDir}/classes/kotlin/test"
)
}
main = "org.openjdk.jmh.Main"
workingDir = rootDir
systemProperty("idea.home.path", project.intellij.localPath)
configurations.plusAssign(project.configurations["compile"])
}