Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Commit

Permalink
Added caches to default mode for running compile-only benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Elena Lepilkina authored and LepilkinaElena committed Dec 30, 2019
1 parent e34344e commit ac03014
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
22 changes: 14 additions & 8 deletions build-tools/src/main/kotlin/org/jetbrains/kotlin/MPPTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.gradle.api.execution.TaskExecutionListener
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeLink
import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.report.*
import org.jetbrains.report.json.*
import java.nio.file.Paths
Expand Down Expand Up @@ -128,14 +129,19 @@ fun mergeReports(reports: List<File>): String {
}
}

fun getCompileOnlyBenchmarksOpts(project: Project, defaultCompilerOpts: List<String>) =
(project.findProperty("nativeBuildType") as String?)?.let {
if (it.equals("RELEASE", true))
listOf("-opt")
else if (it.equals("DEBUG", true))
listOf("-g")
else listOf()
} ?: defaultCompilerOpts
fun getCompileOnlyBenchmarksOpts(project: Project, defaultCompilerOpts: List<String>): List<String> {
val dist = project.file(project.findProperty("kotlin.native.home") ?: "dist")
val useCache = !project.hasProperty("disableCompilerCaches")
val cacheOption = "-Xcache-directory=$dist/klib/cache/${HostManager.host.name}-gSTATIC"
.takeIf { useCache && PlatformInfo.isMac() } // TODO: remove target condition when we have cache support for other targets.
return (project.findProperty("nativeBuildType") as String?)?.let {
if (it.equals("RELEASE", true))
listOf("-opt")
else if (it.equals("DEBUG", true))
listOfNotNull("-g", cacheOption)
else listOf()
} ?: defaultCompilerOpts + listOfNotNull(cacheOption?.takeIf { !defaultCompilerOpts.contains("-opt") })
}

// Find file with set name in directory.
fun findFile(fileName: String, directory: String): String? =
Expand Down
3 changes: 2 additions & 1 deletion performance/helloworld/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ compileBenchmark {
compilerOpts = buildOpts
buildSteps {
step("runKonanc") {
command("$dist/bin/konanc$toolSuffix", "$projectDir/src/main/kotlin/main.kt", "-o", "$buildDir/program$binarySuffix", *(buildOpts.toTypedArray()))
command("$dist/bin/konanc$toolSuffix", "$projectDir/src/main/kotlin/main.kt", "-o",
"$buildDir/program$binarySuffix", *(buildOpts.toTypedArray()))
}
}
}

0 comments on commit ac03014

Please sign in to comment.