Added JS target for benchmarksAnalyzer
This commit is contained in:
committed by
LepilkinaElena
parent
d9474a8319
commit
f47feb9d85
@@ -216,7 +216,9 @@ open class RegressionsReporter : DefaultTask() {
|
||||
"Please check files existance and their correctness.")
|
||||
}
|
||||
|
||||
val reportLink = tabUrl(buildId, buildTypeId, "report_project170_Benchmarks")
|
||||
val reportLink = "http://kotlin-native-performance.labs.jb.gg/?" +
|
||||
"report=bintray:$buildNumber:$target:$bintrayFileName&" +
|
||||
"compareTo=bintray:$compareToBuildNumber:$target:$bintrayFileName"
|
||||
|
||||
val title = "\n*Performance report for target $target (build $buildNumber)* - $reportLink\n"
|
||||
val header = "$title\n$changesInfo\n\nCompare to build $compareToBuildNumber: $compareToBuildLink\n\n"
|
||||
|
||||
@@ -55,6 +55,11 @@ kotlin {
|
||||
implementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion"
|
||||
}
|
||||
}
|
||||
jsTest {
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-test-js:$kotlinVersion"
|
||||
}
|
||||
}
|
||||
nativeMain {
|
||||
dependsOn commonMain
|
||||
kotlin.srcDir 'src/main/kotlin-native'
|
||||
@@ -65,6 +70,12 @@ kotlin {
|
||||
}
|
||||
kotlin.srcDir 'src/main/kotlin-jvm'
|
||||
}
|
||||
jsMain {
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlinVersion"
|
||||
}
|
||||
kotlin.srcDir 'src/main/kotlin-js'
|
||||
}
|
||||
linuxMain { dependsOn nativeMain }
|
||||
windowsMain { dependsOn nativeMain }
|
||||
macosMain {dependsOn nativeMain }
|
||||
@@ -104,6 +115,11 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
fromPreset(presets.js, 'js') {
|
||||
compilations.main.kotlinOptions {
|
||||
main = "noCall"
|
||||
}
|
||||
}
|
||||
|
||||
configure([windows, linux, macos]) {
|
||||
binaries {
|
||||
@@ -123,4 +139,23 @@ def getMingwPath() {
|
||||
if (directory == null)
|
||||
directory = "c:/msys64/mingw64"
|
||||
return directory
|
||||
}
|
||||
|
||||
task assembleWeb(type: Sync) {
|
||||
def runtimeDependencies = kotlin.targets.js.compilations.main.runtimeDependencyFiles
|
||||
from(files {
|
||||
runtimeDependencies.collect { File file ->
|
||||
zipTree(file.absolutePath)
|
||||
}
|
||||
}.builtBy(runtimeDependencies)) {
|
||||
includeEmptyDirs = false
|
||||
include { fileTreeElement ->
|
||||
def path = fileTreeElement.path
|
||||
path.endsWith(".js") && (path.startsWith("META-INF/resources/") ||
|
||||
!path.startsWith("META-INF/"))
|
||||
}
|
||||
}
|
||||
|
||||
from compileKotlinJs.destinationDir
|
||||
into "${projectDir}/web"
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.analyzer
|
||||
|
||||
import org.w3c.xhr.*
|
||||
import kotlin.browser.*
|
||||
import kotlin.js.*
|
||||
|
||||
|
||||
actual fun readFile(fileName: String): String {
|
||||
error("Reading from local file for JS isn't supported")
|
||||
}
|
||||
|
||||
actual fun Double.format(decimalNumber: Int): String =
|
||||
this.asDynamic().toFixed(decimalNumber)
|
||||
|
||||
actual fun writeToFile(fileName: String, text: String) {
|
||||
if (fileName != "html")
|
||||
error("Writing to local file for JS isn't supported")
|
||||
val bodyPart = text.substringAfter("<body>").substringBefore("</body>")
|
||||
document.body?.innerHTML = bodyPart
|
||||
}
|
||||
|
||||
actual fun assert(value: Boolean, lazyMessage: () -> Any) {
|
||||
if (!value) error(lazyMessage)
|
||||
}
|
||||
|
||||
actual fun sendGetRequest(url: String, user: String?, password: String?, followLocation: Boolean) : String {
|
||||
val proxyServerAddress = "https://perf-proxy.labs.jb.gg/"
|
||||
val newUrl = proxyServerAddress + url
|
||||
val request = XMLHttpRequest()
|
||||
|
||||
request.open("GET", newUrl, false, user, password)
|
||||
request.send()
|
||||
if (request.status == 200.toShort()) {
|
||||
return request.responseText
|
||||
}
|
||||
error("Request to $url has status ${request.status}")
|
||||
}
|
||||
@@ -36,9 +36,9 @@ data class MeanVarianceBenchmark(val meanBenchmark: BenchmarkResult, val varianc
|
||||
|
||||
// Calculate difference in percentage compare to another.
|
||||
fun calcPercentageDiff(other: MeanVarianceBenchmark): MeanVariance {
|
||||
assert(other.meanBenchmark.score > 0 &&
|
||||
other.varianceBenchmark.score > 0 &&
|
||||
other.meanBenchmark.score - other.varianceBenchmark.score != 0.0,
|
||||
assert(other.meanBenchmark.score >= 0 &&
|
||||
other.varianceBenchmark.score >= 0 &&
|
||||
abs(other.meanBenchmark.score - other.varianceBenchmark.score) != 0.0,
|
||||
{ "Mean and variance should be positive and not equal!" })
|
||||
val mean = (meanBenchmark.score - other.meanBenchmark.score) / other.meanBenchmark.score
|
||||
val maxValueChange = abs(meanBenchmark.score + varianceBenchmark.score -
|
||||
@@ -55,8 +55,8 @@ data class MeanVarianceBenchmark(val meanBenchmark: BenchmarkResult, val varianc
|
||||
|
||||
// Calculate ratio value compare to another.
|
||||
fun calcRatio(other: MeanVarianceBenchmark): MeanVariance {
|
||||
assert(other.meanBenchmark.score > 0 &&
|
||||
other.varianceBenchmark.score > 0 &&
|
||||
assert(other.meanBenchmark.score >= 0 &&
|
||||
other.varianceBenchmark.score >= 0 &&
|
||||
other.meanBenchmark.score - other.varianceBenchmark.score != 0.0,
|
||||
{ "Mean and variance should be positive and not equal!" })
|
||||
val mean = meanBenchmark.score / other.meanBenchmark.score
|
||||
|
||||
Reference in New Issue
Block a user