Separate performance project (#4473)

This commit is contained in:
LepilkinaElena
2020-10-29 17:05:06 +03:00
committed by Stanislav Erokhin
parent 590aa42f3d
commit e57839ece6
17 changed files with 79 additions and 85 deletions
+16 -8
View File
@@ -134,7 +134,8 @@ To use a local GTest copy instead of the downloaded one, add the following line
To measure performance of Kotlin/Native compiler on existing benchmarks:
./gradlew :performance:konanRun
cd performance
../gradlew :konanRun
**NOTE**: **konanRun** task needs built compiler and libs. To test against working tree make sure to run
@@ -144,19 +145,23 @@ To use a local GTest copy instead of the downloaded one, add the following line
**konanRun** task can be run separately for one/several benchmark applications:
./gradlew :performance:cinterop:konanRun
cd performance
../gradlew :cinterop:konanRun
**konanRun** task has parameter `filter` which allows to run only some subset of benchmarks:
./gradlew :performance:cinterop:konanRun --filter=struct,macros
cd performance
../gradlew :cinterop:konanRun --filter=struct,macros
Or you can use `filterRegex` if you want to specify the filter as regexes:
./gradlew :performance:ring:konanRun --filterRegex=String.*,Loop.*
cd performance
../gradlew :ring:konanRun --filterRegex=String.*,Loop.*
There us also verbose mode to follow progress of running benchmarks
./gradlew :performance:cinterop:konanRun --verbose
cd performance
../gradlew :cinterop:konanRun --verbose
> Task :performance:cinterop:konanRun
[DEBUG] Warm up iterations for benchmark macros
@@ -165,16 +170,19 @@ To use a local GTest copy instead of the downloaded one, add the following line
There are also tasks for running benchmarks on JVM (pay attention, some benchmarks e.g. cinterop benchmarks can't be run on JVM)
./gradlew :performance:jvmRun
cd performance
../gradlew :jvmRun
Files with results of benchmarks run are saved in `performance/build/nativeReport.json` for konanRun and `jvmReport.json` for jvmRun.
You can change the output filename by setting the `nativeJson` property for konanRun and `jvmJson` for jvmRun:
./gradlew :performance:ring:konanRun --filter=String.*,Loop.* -PnativeJson=stringsAndLoops.json
cd performance
../gradlew :ring:konanRun --filter=String.*,Loop.* -PnativeJson=stringsAndLoops.json
You can use the `compilerArgs` property to pass flags to the compiler used to compile the benchmarks:
./gradlew :performance:konanRun -PcompilerArgs="--time -g"
cd performance
../gradlew :konanRun -PcompilerArgs="--time -g"
To compare different results run benchmarksAnalyzer tool:
@@ -71,6 +71,7 @@ open class BenchmarkExtension @Inject constructor(val project: Project) {
var compilerOpts: List<String> = emptyList()
var buildType: NativeBuildType = NativeBuildType.RELEASE
var repeatingType: BenchmarkRepeatingType = BenchmarkRepeatingType.INTERNAL
var cleanBeforeRunTask: String? = "konanRun"
val dependencies: BenchmarkDependencies = BenchmarkDependencies()
@@ -256,6 +257,11 @@ abstract class BenchmarkingPlugin: Plugin<Project> {
// JVM report task.
configureJvmJsonTask(jvmRun)
project.afterEvaluate {
// Need to rebuild benchmark to collect compile time.
project.benchmark.cleanBeforeRunTask?.let { tasks.getByName(it).dependsOn("clean") }
}
}
override fun apply(target: Project) = with(target) {
-6
View File
@@ -668,12 +668,6 @@ task samples {
dependsOn 'samplesZip', 'samplesTar'
}
task performance {
dependsOn 'dist'
dependsOn ':performance:clean'
dependsOn ':performance:konanRun'
}
task samplesZip(type: Zip)
task samplesTar(type: Tar) {
extension = 'tar.gz'
@@ -1,5 +1,5 @@
buildscript {
apply from: "$rootProject.projectDir/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootProject.projectDir/../gradle/kotlinGradlePlugin.gradle"
repositories {
maven {
url 'https://cache-redirector.jetbrains.com/jcenter'
@@ -18,5 +18,4 @@ swiftBenchmark {
swiftSources = File("$projectDir/src").list().map { "$projectDir/src/$it" }.toList()
compileTasks = listOf("buildSwift")
useCodeSize = CodeSizeEntity.EXECUTABLE
dependencies.common(project(":endorsedLibraries:kotlinx.cli"))
}
+15 -4
View File
@@ -4,12 +4,23 @@ import org.jetbrains.kotlin.BuildRegister
import org.jetbrains.kotlin.MPPTools
buildscript {
apply from: "$rootProject.projectDir/gradle/kotlinGradlePlugin.gradle"
ext.rootBuildDirectory = file('..')
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
repositories {
maven {
url 'https://cache-redirector.jetbrains.com/jcenter'
}
maven { url 'https://cache-redirector.jetbrains.com/jcenter'}
maven { url 'https://cache-redirector.jetbrains.com/maven-central' }
mavenCentral()
maven { url buildKotlinCompilerRepo }
maven { url kotlinCompilerRepo }
jcenter()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url "https://dl.bintray.com/kotlin/kotlin-dev" }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-native-build-tools:$konanVersion"
}
}
@@ -20,7 +20,6 @@ benchmark {
mingwSrcDirs = listOf("src/main/kotlin-native", "../shared/src/main/kotlin-native/mingw")
posixSrcDirs = listOf("src/main/kotlin-native", "../shared/src/main/kotlin-native/posix")
buildType = (findProperty("nativeBuildType") as String?)?.let { NativeBuildType.valueOf(it) } ?: defaultBuildType
dependencies.common(project(":endorsedLibraries:kotlinx.cli"))
}
val native = kotlin.targets.getByName("native") as KotlinNativeTarget
@@ -4,7 +4,7 @@ import org.jetbrains.kotlin.RunJvmTask
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
buildscript {
apply from: "$rootProject.projectDir/gradle/kotlinGradlePlugin.gradle"
apply from: "$rootProject.projectDir/../gradle/kotlinGradlePlugin.gradle"
repositories {
maven {
@@ -42,8 +42,8 @@ kotlin {
}
kotlin.srcDir "$toolsPath/benchmarks/shared/src"
kotlin.srcDir "$toolsPath/benchmarksAnalyzer/src/main/kotlin"
kotlin.srcDir "$rootProject.projectDir/endorsedLibraries/kotlinx.cli/src/main/kotlin"
kotlin.srcDir "$rootProject.projectDir/endorsedLibraries/kotlinx.cli/src/main/kotlin-native"
kotlin.srcDir "$rootProject.projectDir/../endorsedLibraries/kotlinx.cli/src/main/kotlin"
kotlin.srcDir "$rootProject.projectDir/../endorsedLibraries/kotlinx.cli/src/main/kotlin-native"
kotlin.srcDir "$toolsPath/benchmarksAnalyzer/src/main/kotlin-native"
}
}
@@ -7,7 +7,7 @@ import org.jetbrains.kotlin.benchmark.BenchmarkingPlugin
import org.jetbrains.kotlin.ExecClang
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.kotlin.konan.target.*
plugins {
id("benchmarking")
@@ -22,24 +22,7 @@ benchmark {
nativeSrcDirs = listOf("src/main/kotlin-native", "../shared/src/main/kotlin-native/common")
mingwSrcDirs = listOf("../shared/src/main/kotlin-native/mingw")
posixSrcDirs = listOf("../shared/src/main/kotlin-native/posix")
linkerOpts = listOf("$buildDir/pi.o")
buildType = (findProperty("nativeBuildType") as String?)?.let { NativeBuildType.valueOf(it) } ?: defaultBuildType
dependencies.common(project(":endorsedLibraries:kotlinx.cli"))
}
val compileLibary by tasks.creating {
doFirst {
mkdir(buildDir)
project.withConvention(ExecClang::class) {
execKonanClang(HostManager.host) {
args("-O3")
args("-c", "$projectDir/src/nativeInterop/cinterop/pi.c")
args("-o", "$buildDir/pi.o")
}
}
}
}
val native = kotlin.targets.getByName("native") as KotlinNativeTarget
@@ -47,7 +30,8 @@ native.apply {
compilations["main"].cinterops {
create("cinterop") {
headers("$projectDir/src/nativeInterop/cinterop/pi.h")
extraOpts("-Xcompile-source", "$projectDir/src/nativeInterop/cinterop/pi.c")
extraOpts("-Xsource-compiler-option", "-O3")
}
}
binaries.getExecutable(BenchmarkingPlugin.NATIVE_EXECUTABLE_NAME, "RELEASE").linkTask.dependsOn(compileLibary)
}
@@ -15,6 +15,7 @@
*/
#include <math.h>
#include "pi.h"
/* uncomment the following line to use 'long long' integers */
#define HAS_LONG_LONG
@@ -11,6 +11,12 @@
#ifndef _BELLARD_PI_H
#define _BELLARD_PI_H
#ifdef __cplusplus
extern "C" {
#endif
int pi_nth_digit(int n);
#ifdef __cplusplus
}
#endif
#endif /*_BELLARD_PI_H*/
@@ -22,32 +22,17 @@ benchmark {
nativeSrcDirs = listOf("src/main/kotlin-native", "../shared/src/main/kotlin-native/common")
mingwSrcDirs = listOf("src/main/kotlin-native", "../shared/src/main/kotlin-native/mingw")
posixSrcDirs = listOf("src/main/kotlin-native", "../shared/src/main/kotlin-native/posix")
linkerOpts = listOf("-L$buildDir", "-lcomplexnumbers")
buildType = (findProperty("nativeBuildType") as String?)?.let { NativeBuildType.valueOf(it) } ?: defaultBuildType
dependencies.common(project(":endorsedLibraries:kotlinx.cli"))
}
val compileLibary by tasks.creating {
doFirst {
mkdir(buildDir)
project.withConvention(ExecClang::class) {
execKonanClang(HostManager.host) {
args("$projectDir/src/nativeInterop/cinterop/complexNumbers.m")
args("-lobjc", "-fobjc-arc")
args("-fPIC", "-shared", "-o", "$buildDir/libcomplexnumbers.dylib")
}
}
}
}
val native = kotlin.targets.getByName("native") as KotlinNativeTarget
native.apply {
compilations["main"].cinterops {
create("classes") {
headers("$projectDir/src/nativeInterop/cinterop/complexNumbers.h")
extraOpts("-Xcompile-source", "$projectDir/src/nativeInterop/cinterop/complexNumbers.m")
extraOpts("-Xsource-compiler-option", "-lobjc", "-Xsource-compiler-option", "-fobjc-arc")
}
}
binaries.getExecutable(BenchmarkingPlugin.NATIVE_EXECUTABLE_NAME, "RELEASE").linkTask.dependsOn(compileLibary)
}
@@ -19,6 +19,4 @@ benchmark {
mingwSrcDirs = listOf("src/main/kotlin-native", "../shared/src/main/kotlin-native/mingw")
posixSrcDirs = listOf("src/main/kotlin-native", "../shared/src/main/kotlin-native/posix")
buildType = (findProperty("nativeBuildType") as String?)?.let { NativeBuildType.valueOf(it) } ?: defaultBuildType
dependencies.common(project(":endorsedLibraries:kotlinx.cli"))
}
+23
View File
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
include ':ring'
include ':cinterop'
include ':helloworld'
include ':numerical'
include ':videoplayer'
include ':framework'
include ':startup'
if (System.getProperty("os.name") == "Mac OS X") {
include ':objcinterop'
include ':swiftinterop'
if (hasProperty("runExcludedBenchmarks")) {
include ':KotlinVsSwift'
include ':KotlinVsSwift:ring'
}
}
includeBuild '../build-tools'
@@ -22,6 +22,4 @@ benchmark {
posixSrcDirs = listOf("../shared/src/main/kotlin-native/posix")
buildType = (findProperty("nativeBuildType") as String?)?.let { NativeBuildType.valueOf(it) } ?: defaultBuildType
repeatingType = BenchmarkRepeatingType.EXTERNAL
dependencies.common(project(":endorsedLibraries:kotlinx.cli"))
}
@@ -1,5 +1,5 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
import org.jetbrains.kotlin.konan.target.*
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
@@ -12,7 +12,7 @@ plugins {
val toolsPath = "../../tools"
val targetExtension = "Macos"
val defaultBuildType = NativeBuildType.RELEASE
project.extra["platformManager"] = PlatformManager(projectDir.parentFile.parentFile.absolutePath, false)
swiftBenchmark {
applicationName = "swiftInterop"
commonSrcDirs = listOf("$toolsPath/benchmarks/shared/src/main/kotlin/report", "src", "../shared/src/main/kotlin")
@@ -20,6 +20,5 @@ swiftBenchmark {
swiftSources = listOf("$projectDir/swiftSrc/benchmarks.swift", "$projectDir/swiftSrc/main.swift")
compileTasks = listOf("compileKotlinNative", "linkBenchmarkReleaseFrameworkNative")
buildType = (findProperty("nativeBuildType") as String?)?.let { NativeBuildType.valueOf(it) } ?: defaultBuildType
dependencies.common(project(":endorsedLibraries:kotlinx.cli"))
cleanBeforeRunTask = "compileKotlinNative"
}
-17
View File
@@ -33,23 +33,6 @@ include ':utilities:basic-utils'
include ':utilities:cli-runner'
include ':dependencyPacker'
include ':performance'
include ':performance:ring'
include ':performance:cinterop'
include ':performance:helloworld'
include ':performance:numerical'
include ':performance:videoplayer'
include ':performance:framework'
include ':performance:startup'
if (System.getProperty("os.name") == "Mac OS X") {
include ':performance:objcinterop'
include ':performance:swiftinterop'
if (hasProperty("runExcludedBenchmarks")) {
include ':performance:KotlinVsSwift'
include ':performance:KotlinVsSwift:ring'
}
}
include ':platformLibs'
include ':endorsedLibraries'
include ':endorsedLibraries:kotlinx.cli'