[performance] compilation and execution with kotlin native and jvm, comparing results

This commit is contained in:
Vasily Levchenko
2017-08-28 13:49:47 +03:00
committed by Vasily Levchenko
parent 136c62a62c
commit 403c774688
4 changed files with 106 additions and 7 deletions
+2 -1
View File
@@ -27,6 +27,7 @@ ext {
dependenciesDir = rootProject.file("dist/dependencies")
clangManager = new ClangManager(konanProperties, dependenciesDir.absolutePath)
kotlinCompilerModule="org.jetbrains.kotlin:kotlin-compiler:${kotlinVersion}"
}
allprojects {
@@ -314,7 +315,7 @@ task performance(type: GradleBuild) {
dependsOn ':tools:kotlin-native-gradle-plugin:jar'
dir = 'performance'
tasks = ['build', 'run']
tasks = ['build', 'bench']
doFirst {
startParameter.projectProperties['konanPluginClasspath'] =
+6 -1
View File
@@ -23,6 +23,11 @@ testDataVersion=1067176:id
kotlinCompilerRepo=https://dl.bintray.com/jetbrains/kotlin-native-dependencies
#kotlinCompilerRepo=http://oss.sonatype.org/content/repositories/snapshots
#kotlinCompilerRepo=http://dl.bintray.com/kotlin/kotlin-dev
kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20170826.093556-820
kotlinVersion=1.1-20170826.093556-820
konanVersion=0.3.1
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
##
# required for performance mesuarement tasks
kotlinStdLibJdk8Version=1.1-20170822.213444-718
kotlinGradlePluginVersion=1.1-20170821.192225-785
+97 -4
View File
@@ -1,20 +1,113 @@
import org.jetbrains.kotlin.konan.target.KonanTarget
//evaluationDependsOn(":tools:kotlin-native-gradle-plugin")
buildscript {
def rootProperties = new Properties()
rootProperties.load(new FileReader(project.file('../gradle.properties')))
rootProperties.each {k, v -> ext.set(k, v)}
repositories {
mavenCentral()
maven {
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
//TODO: this path should be removed!!
url "https://oss.sonatype.org/content/repositories/snapshots"
}
maven {
url rootProperties.kotlinCompilerRepo
}
mavenCentral()
}
dependencies {
classpath files(konanPluginClasspath)
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinGradlePluginVersion"
classpath files(project.file('../tools/kotlin-native-gradle-plugin/build/libs').listFiles().findAll{it.name.endsWith('.jar')}.collect().first().absolutePath)
}
}
repositories {
maven {
//TODO: this path should be removed!!
url "https://oss.sonatype.org/content/repositories/snapshots"
}
maven {
url kotlinCompilerRepo
}
mavenCentral()
}
//TODO: property
def ringWarmup=1000
def iterations=2000
apply plugin: 'kotlin'
apply plugin: 'application'
apply plugin: 'konan'
konanArtifacts {
Ring {
enableOptimization()
}
}
}
compileKotlin {
kotlinOptions.suppressWarnings = true
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinStdLibJdk8Version"
}
task jvmRun(type: JavaExec) {
def output = new FileOutputStream("${buildDir.absolutePath}/jvmReport.txt")
classpath sourceSets.main.runtimeClasspath
main = "MainKt"
args "$ringWarmup", "$iterations"
standardOutput = output
doLast {
output.close()
}
}
task konanRun(type: Exec) {
def output = new FileOutputStream("${buildDir.absolutePath}/konanReport.txt")
commandLine project.file("build/konan/bin/Ring.kexe").absolutePath, "$ringWarmup", "$iterations"
standardOutput = output
doLast {
output.close()
}
}
startScripts{
setEnabled(false)
}
task bench(type:DefaultTask) {
dependsOn jvmRun
dependsOn konanRun
doLast {
def jvmReport = new Report(project.file("build/jvmReport.txt"))
def konanReport = new Report(project.file("build/konanReport.txt"))
jvmReport.report.each { k, v ->
def ratio = String.format('%.2f', konanReport.report[k]/v * 100)
println("$k : $ratio %")
if (System.getenv("TEAMCITY_BUILD_PROPERTIES_FILE") != null)
println("##teamcity[buildStatisticValue key='$k' value='$ratio']")
}
}
}
class Report {
def Map<String, Double> report = new HashMap()
Report(File path) {
path.readLines().drop(3).takeWhile { it.split(':').length == 2 }.each {
def p = it.split(':')
report.put(p[0].trim(), Double.parseDouble(p[1].trim()))
}
}
}
+1 -1
View File
@@ -27,4 +27,4 @@ include ':common'
include ':backend.native:tests'
include ':shared'
include ':tools:kotlin-native-gradle-plugin'
include ':utilities'
include ':utilities'