forked from JetBrains/kotlin-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[performance] compilation and execution with kotlin native and jvm, c…
…omparing results
- Loading branch information
1 parent
136c62a
commit 403c774
Showing
4 changed files
with
106 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { | ||
//TODO: this path should be removed!! | ||
url "https://oss.sonatype.org/content/repositories/snapshots" | ||
} | ||
maven { | ||
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies" | ||
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())) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters