Added measuring code size for full application
This commit is contained in:
committed by
LepilkinaElena
parent
f47feb9d85
commit
f54f570fbf
@@ -41,6 +41,7 @@ private def determinePreset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def hostPreset = determinePreset()
|
def hostPreset = determinePreset()
|
||||||
|
def applicationName = 'Ring'
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
@@ -104,13 +105,15 @@ task jvmRun(type: JavaExec) {
|
|||||||
|
|
||||||
task konanJsonReport {
|
task konanJsonReport {
|
||||||
doLast {
|
doLast {
|
||||||
def nativeCompileTime = MPPTools.getNativeCompileTime('Ring')
|
def nativeExecutable = MPPTools.getKotlinNativeExecutable(kotlin.targets.native, "RELEASE")
|
||||||
|
def nativeCompileTime = MPPTools.getNativeCompileTime(applicationName)
|
||||||
String benchContents = new File("${buildDir.absolutePath}/${nativeBenchResults}").text
|
String benchContents = new File("${buildDir.absolutePath}/${nativeBenchResults}").text
|
||||||
def properties = getCommonProperties() + ['type' : 'native',
|
def properties = getCommonProperties() + ['type' : 'native',
|
||||||
'compilerVersion': "${konanVersion}".toString(),
|
'compilerVersion': "${konanVersion}".toString(),
|
||||||
'flags' : kotlin.targets.native.compilations.main.extraOpts.collect{ '"' + it + '"'},
|
'flags' : kotlin.targets.native.compilations.main.extraOpts.collect{ "\"$it\"" },
|
||||||
'benchmarks' : benchContents,
|
'benchmarks' : benchContents,
|
||||||
'compileTime' : nativeCompileTime]
|
'compileTime' : nativeCompileTime,
|
||||||
|
'codeSize' : MPPTools.getCodeSizeBenchmark(applicationName, nativeExecutable) ]
|
||||||
def output = MPPTools.createJsonReport(properties)
|
def output = MPPTools.createJsonReport(properties)
|
||||||
new File("${buildDir.absolutePath}/${nativeJson}").write(output)
|
new File("${buildDir.absolutePath}/${nativeJson}").write(output)
|
||||||
uploadBenchmarkResultToBintray(nativeJson)
|
uploadBenchmarkResultToBintray(nativeJson)
|
||||||
@@ -119,12 +122,14 @@ task konanJsonReport {
|
|||||||
|
|
||||||
task jvmJsonReport {
|
task jvmJsonReport {
|
||||||
doLast {
|
doLast {
|
||||||
def jvmCompileTime = MPPTools.getJvmCompileTime('Ring')
|
def jarPath = project.getTasks().getByName("jvmJar").archivePath
|
||||||
|
def jvmCompileTime = MPPTools.getJvmCompileTime(applicationName)
|
||||||
String benchContents = new File("${buildDir.absolutePath}/${jvmBenchResults}").text
|
String benchContents = new File("${buildDir.absolutePath}/${jvmBenchResults}").text
|
||||||
def properties = getCommonProperties() + ['type' : 'jvm',
|
def properties = getCommonProperties() + ['type' : 'jvm',
|
||||||
'compilerVersion': "${buildKotlinVersion}".toString(),
|
'compilerVersion': "${buildKotlinVersion}".toString(),
|
||||||
'benchmarks' : benchContents,
|
'benchmarks' : benchContents,
|
||||||
'compileTime' : jvmCompileTime]
|
'compileTime' : jvmCompileTime,
|
||||||
|
'codeSize' : MPPTools.getCodeSizeBenchmark(applicationName, "${jarPath}") ]
|
||||||
def output = MPPTools.createJsonReport(properties)
|
def output = MPPTools.createJsonReport(properties)
|
||||||
new File("${buildDir.absolutePath}/${jvmJson}").write(output)
|
new File("${buildDir.absolutePath}/${jvmJson}").write(output)
|
||||||
uploadBenchmarkResultToBintray(jvmJson)
|
uploadBenchmarkResultToBintray(jvmJson)
|
||||||
|
|||||||
@@ -76,6 +76,21 @@ fun getNativeProgramExtension(): String = when {
|
|||||||
else -> error("Unknown host")
|
else -> error("Unknown host")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getKotlinNativeExecutable(target: KotlinTarget, buildType: String) =
|
||||||
|
target.compilations.main.getBinary("EXECUTABLE", buildType).toString()
|
||||||
|
|
||||||
|
fun getFileSize(filePath: String): Long? {
|
||||||
|
val file = File(filePath)
|
||||||
|
return if (file.exists()) file.length() else null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCodeSizeBenchmark(programName: String, filePath: String): BenchmarkResult {
|
||||||
|
val codeSize = getFileSize(filePath)
|
||||||
|
return BenchmarkResult("$programName.codeSize",
|
||||||
|
codeSize?. let { BenchmarkResult.Status.PASSED } ?: run { BenchmarkResult.Status.FAILED },
|
||||||
|
codeSize?.toDouble() ?: 0.0, codeSize?.toDouble() ?: 0.0, 1, 0)
|
||||||
|
}
|
||||||
|
|
||||||
// Create benchmarks json report based on information get from gradle project
|
// Create benchmarks json report based on information get from gradle project
|
||||||
fun createJsonReport(projectProperties: Map<String, Any>): String {
|
fun createJsonReport(projectProperties: Map<String, Any>): String {
|
||||||
fun getValue(key: String): String = projectProperties[key] as? String ?: "unknown"
|
fun getValue(key: String): String = projectProperties[key] as? String ?: "unknown"
|
||||||
@@ -89,7 +104,8 @@ fun createJsonReport(projectProperties: Map<String, Any>): String {
|
|||||||
val benchDesc = getValue("benchmarks")
|
val benchDesc = getValue("benchmarks")
|
||||||
val benchmarksArray = JsonTreeParser.parse(benchDesc)
|
val benchmarksArray = JsonTreeParser.parse(benchDesc)
|
||||||
val benchmarks = BenchmarksReport.parseBenchmarksArray(benchmarksArray)
|
val benchmarks = BenchmarksReport.parseBenchmarksArray(benchmarksArray)
|
||||||
.union(listOf<BenchmarkResult>(projectProperties["compileTime"] as BenchmarkResult)).toList()
|
.union(listOf<BenchmarkResult>(projectProperties["compileTime"] as BenchmarkResult,
|
||||||
|
projectProperties["codeSize"] as BenchmarkResult)).toList()
|
||||||
val report = BenchmarksReport(env, benchmarks, kotlin)
|
val report = BenchmarksReport(env, benchmarks, kotlin)
|
||||||
return report.toJson()
|
return report.toJson()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import org.w3c.xhr.*
|
|||||||
import kotlin.browser.*
|
import kotlin.browser.*
|
||||||
import kotlin.js.*
|
import kotlin.js.*
|
||||||
|
|
||||||
|
|
||||||
actual fun readFile(fileName: String): String {
|
actual fun readFile(fileName: String): String {
|
||||||
error("Reading from local file for JS isn't supported")
|
error("Reading from local file for JS isn't supported")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ data class MeanVarianceBenchmark(val meanBenchmark: BenchmarkResult, val varianc
|
|||||||
fun calcPercentageDiff(other: MeanVarianceBenchmark): MeanVariance {
|
fun calcPercentageDiff(other: MeanVarianceBenchmark): MeanVariance {
|
||||||
assert(other.meanBenchmark.score >= 0 &&
|
assert(other.meanBenchmark.score >= 0 &&
|
||||||
other.varianceBenchmark.score >= 0 &&
|
other.varianceBenchmark.score >= 0 &&
|
||||||
abs(other.meanBenchmark.score - other.varianceBenchmark.score) != 0.0,
|
other.meanBenchmark.score - other.varianceBenchmark.score != 0.0,
|
||||||
{ "Mean and variance should be positive and not equal!" })
|
{ "Mean and variance should be positive and not equal!" })
|
||||||
val mean = (meanBenchmark.score - other.meanBenchmark.score) / other.meanBenchmark.score
|
val mean = (meanBenchmark.score - other.meanBenchmark.score) / other.meanBenchmark.score
|
||||||
val maxValueChange = abs(meanBenchmark.score + varianceBenchmark.score -
|
val maxValueChange = abs(meanBenchmark.score + varianceBenchmark.score -
|
||||||
|
|||||||
Reference in New Issue
Block a user