diff --git a/kotlin-native/tools/benchmarksAnalyzer/build.gradle b/kotlin-native/tools/benchmarksAnalyzer/build.gradle index dc9507a985d..1872fc8632b 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/build.gradle +++ b/kotlin-native/tools/benchmarksAnalyzer/build.gradle @@ -156,7 +156,7 @@ kotlin { } } } - fromPreset(presets.js, 'js') { + fromPreset(presets.jsIr, 'js') { compilations.main.kotlinOptions { main = "noCall" } @@ -184,7 +184,7 @@ kotlin { } } - js { + js(IR) { browser { distribution { directory = new File("$projectDir/web/") diff --git a/kotlin-native/tools/performance-server/shared/src/main/kotlin/org/jetbrains/elastic/ElasticSearchIndex.kt b/kotlin-native/tools/performance-server/shared/src/main/kotlin/org/jetbrains/elastic/ElasticSearchIndex.kt index 216cf04c37a..dd930c2ee90 100644 --- a/kotlin-native/tools/performance-server/shared/src/main/kotlin/org/jetbrains/elastic/ElasticSearchIndex.kt +++ b/kotlin-native/tools/performance-server/shared/src/main/kotlin/org/jetbrains/elastic/ElasticSearchIndex.kt @@ -119,7 +119,7 @@ data class BuildInfo(val buildNumber: String, val startTime: String, val endTime val buildTypeElement = data.getOptionalField("buildType") val buildType = buildTypeElement?.let { elementToString(buildTypeElement, "buildType") - } ?: null + } return BuildInfo(buildNumber, startTime, endTime, CommitsList(commits), branch, agentInfo, buildType) } else { error("Top level entity is expected to be an object. Please, check origin files.") @@ -161,7 +161,7 @@ abstract class ElasticSearchIndex(val indexName: String, val connector: ElasticS "mappings": { "properties": { ${mapping.map { (property, type) -> - "\"${property}\": { \"type\": \"${type.name.toLowerCase()}\"${if (type == ElasticSearchType.DATE) "," + + "\"${property}\": { \"type\": \"${type.name.lowercase()}\"${if (type == ElasticSearchType.DATE) "," + "\"format\": \"basic_date_time_no_millis\"" else ""} }" }.joinToString()}} } diff --git a/kotlin-native/tools/performance-server/src/main/kotlin/database/BenchmarksIndexesDispatcher.kt b/kotlin-native/tools/performance-server/src/main/kotlin/database/BenchmarksIndexesDispatcher.kt index 5d445c29b17..72752709348 100644 --- a/kotlin-native/tools/performance-server/src/main/kotlin/database/BenchmarksIndexesDispatcher.kt +++ b/kotlin-native/tools/performance-server/src/main/kotlin/database/BenchmarksIndexesDispatcher.kt @@ -27,7 +27,7 @@ class BenchmarksIndexesDispatcher(connector: ElasticSearchConnector, val feature // Becnhmarks indexes to work with in case of existing feature values. private val benchmarksIndexes = if (featureValues.isNotEmpty()) - featureValues.map { it to BenchmarksIndex("benchmarks_${it.replace(" ", "_").toLowerCase()}", connector) } + featureValues.map { it to BenchmarksIndex("benchmarks_${it.replace(" ", "_").lowercase()}", connector) } .toMap() else emptyMap() @@ -122,7 +122,7 @@ class BenchmarksIndexesDispatcher(connector: ElasticSearchConnector, val feature "bool": { "must": [ { "match": { "benchmarks.metric": "$metricName" } }, - { "terms": { "benchmarks.name": [${samples.map { "\"${it.toLowerCase()}\"" }.joinToString()}] }} + { "terms": { "benchmarks.name": [${samples.map { "\"${it.lowercase()}\"" }.joinToString()}] }} ] } }, "inner_hits": { diff --git a/kotlin-native/tools/performance-server/src/main/kotlin/database/DatabaseRequests.kt b/kotlin-native/tools/performance-server/src/main/kotlin/database/DatabaseRequests.kt index dbac550f8fd..ef44ae6101d 100644 --- a/kotlin-native/tools/performance-server/src/main/kotlin/database/DatabaseRequests.kt +++ b/kotlin-native/tools/performance-server/src/main/kotlin/database/DatabaseRequests.kt @@ -50,7 +50,7 @@ internal fun getBuildsDescription(type: String?, branch: String?, agentInfo: Str { "regexp": { "buildNumber": { "value": "${if (it == "release") ".*eap.*|.*release.*|.*rc.*" else ".*dev.*"}" } } }, - { "match": { "buildType": "${it.toUpperCase()}" } } + { "match": { "buildType": "${it.uppercase()}" } } ] }}, { "bool": { diff --git a/kotlin-native/tools/performance-server/src/main/kotlin/main.kt b/kotlin-native/tools/performance-server/src/main/kotlin/main.kt index 8c76e121db7..6f7cbe0447c 100644 --- a/kotlin-native/tools/performance-server/src/main/kotlin/main.kt +++ b/kotlin-native/tools/performance-server/src/main/kotlin/main.kt @@ -10,7 +10,7 @@ external fun require(module: String): dynamic external val process: dynamic external val __dirname: dynamic -fun main(args: Array) { +fun main() { println("Server Starting!") val express = require("express") @@ -28,7 +28,7 @@ fun main(args: Array) { app.set("view engine", "ejs") app.use(express.static("ui")) - val server = http.createServer(app) + http.createServer(app) app.listen(port, { println("App listening on port " + port + "!") }) diff --git a/kotlin-native/tools/performance-server/src/main/kotlin/network/CachableResponseDispatcher.kt b/kotlin-native/tools/performance-server/src/main/kotlin/network/CachableResponseDispatcher.kt index f685d9f08cc..bb24fdaf7fd 100644 --- a/kotlin-native/tools/performance-server/src/main/kotlin/network/CachableResponseDispatcher.kt +++ b/kotlin-native/tools/performance-server/src/main/kotlin/network/CachableResponseDispatcher.kt @@ -24,7 +24,7 @@ object CachableResponseDispatcher { action: (success: (result: Any) -> Unit, reject: () -> Unit) -> Unit) { cachedResponses[request.url]?.let { // Update cache value if needed. Update only if last result was get later than 2 minutes. - if (it.time.elapsedNow().inMinutes > 2.0) { + if (it.time.elapsedNow().inWholeMinutes >= 2.0) { println("Cache update for ${request.url}...") action({ result: Any -> cachedResponses[request.url] = CachedResponse(result, TimeSource.Monotonic.markNow()) diff --git a/kotlin-native/tools/performance-server/src/main/kotlin/routes/route.kt b/kotlin-native/tools/performance-server/src/main/kotlin/routes/route.kt index c01283e66c0..1fcc49e7caa 100644 --- a/kotlin-native/tools/performance-server/src/main/kotlin/routes/route.kt +++ b/kotlin-native/tools/performance-server/src/main/kotlin/routes/route.kt @@ -45,6 +45,7 @@ internal fun convertToNewFormat(data: JsonObject): List { } // Convert data results to expected format. +@Suppress("UNCHECKED_CAST") internal fun convert(json: String, buildNumber: String, target: String): List { val data = JsonTreeParser.parse(json) val reports = if (data is JsonArray) { @@ -143,12 +144,12 @@ data class BuildRegister(val buildId: String, val teamCityUser: String, val team val data = JsonTreeParser.parse(response).jsonObject data.getArray("build").forEach { (it as JsonObject).getObject("revisions").getArray("revision").forEach { - val currentBranch = (it as JsonObject).getPrimitive("vcsBranchName").content.removePrefix("refs/heads/") - val currentProject = (it as JsonObject).getObject("vcs-root-instance").getPrimitive("name").content + it as JsonObject + val currentBranch = it.getPrimitive("vcsBranchName").content.removePrefix("refs/heads/") + val currentProject = it.getObject("vcs-root-instance").getPrimitive("name").content if (projects.anyMatches(currentProject)) { branch = currentBranch } - return@forEach } } branch ?: error("No project from list $projects can be found in build $buildId") @@ -476,7 +477,7 @@ fun router(networkConnector: NetworkConnector) { distinctValues("branch", buildInfoIndex).then { results -> success(results) }.catch { errorMessage -> - error(errorMessage.message ?: "Failed getting branches list.") + println(errorMessage.message ?: "Failed getting branches list.") reject() } } diff --git a/kotlin-native/tools/performance-server/ui/build.gradle b/kotlin-native/tools/performance-server/ui/build.gradle index f6fbdc586a4..cf66304a60c 100644 --- a/kotlin-native/tools/performance-server/ui/build.gradle +++ b/kotlin-native/tools/performance-server/ui/build.gradle @@ -51,7 +51,7 @@ repositories { apply plugin: 'kotlin-multiplatform' kotlin { - js { + js(IR) { browser { binaries.executable() distribution { diff --git a/kotlin-native/tools/performance-server/ui/src/main/kotlin/main.kt b/kotlin-native/tools/performance-server/ui/src/main/kotlin/main.kt index d8bf70657f4..02a4a97822d 100644 --- a/kotlin-native/tools/performance-server/ui/src/main/kotlin/main.kt +++ b/kotlin-native/tools/performance-server/ui/src/main/kotlin/main.kt @@ -103,8 +103,7 @@ fun customizeChart(chart: dynamic, chartContainer: String, jquerySelector: dynam var element = data.element if (data.type == "point") { val pointSize = 12 - val currentBuild = builds.get(data.index) - currentBuild?.let { currentBuild -> + builds.get(data.index)?.let { currentBuild -> // Higlight builds with failures. if (currentBuild.failuresNumber > 0) { val svgParameters: dynamic = object {} @@ -148,9 +147,10 @@ fun customizeChart(chart: dynamic, chartContainer: String, jquerySelector: dynam append("time: ${currentBuild.formattedStartTime}-${currentBuild.formattedFinishTime}
") append("Commits:
") val commitsList = (JsonTreeParser.parse("{${currentBuild.commits}}") as JsonObject).getArray("commits").map { + it as JsonObject Commit( - (it as JsonObject).getPrimitive("revision").content, - (it as JsonObject).getPrimitive("developer").content + it.getPrimitive("revision").content, + it.getPrimitive("developer").content ) } val commits = if (commitsList.size > 3) commitsList.slice(0..2) else commitsList @@ -171,11 +171,11 @@ fun customizeChart(chart: dynamic, chartContainer: String, jquerySelector: dynam }) chart.on("created", { val currentChart = jquerySelector - val parameters: dynamic = object {} - parameters["selector"] = "[data-chart-tooltip=\"$chartContainer\"]" - parameters["container"] = "#$chartContainer" - parameters["html"] = true - currentChart.tooltip(parameters) + val chartParameters: dynamic = object {} + chartParameters["selector"] = "[data-chart-tooltip=\"$chartContainer\"]" + chartParameters["container"] = "#$chartContainer" + chartParameters["html"] = true + currentChart.tooltip(chartParameters) }) } @@ -189,7 +189,7 @@ external fun encodeURIComponent(url: String): String fun getDatesComponents() = "${beforeDate?.let {"&before=${encodeURIComponent(it)}"} ?: ""}" + "${afterDate?.let {"&after=${encodeURIComponent(it)}"} ?: ""}" -fun main(args: Array) { +fun main() { val serverUrl = window.location.origin // use "http://localhost:3000" for local debug. val zoomRatio = 2 @@ -216,6 +216,7 @@ fun main(args: Array) { // Add release branches to selector. branches.filter { it != "master" }.forEach { if ("^v?(\\d|\\.)+(-M\\d)?(-fixes)?$".toRegex().matches(it)) { + @Suppress("UNUSED_VARIABLE") // it's used within js block val option = Option(it, it) js("$('#inputGroupBranch')").append(js("$(option)")) } @@ -310,8 +311,7 @@ fun main(args: Array) { val metricUrl = "$serverUrl/metricValue/${parameters["target"]}/" - val unstableBenchmarksPromise = sendGetRequest("$serverUrl/unstable").then { response -> - val unstableList = response as String + val unstableBenchmarksPromise = sendGetRequest("$serverUrl/unstable").then { unstableList -> val data = JsonTreeParser.parse(unstableList) if (data !is JsonArray) { error("Response is expected to be an array.") @@ -322,15 +322,13 @@ fun main(args: Array) { } // Get builds description. - val buildsInfoPromise = sendGetRequest(descriptionUrl).then { response -> - val buildsInfo = response as String + val buildsInfoPromise = sendGetRequest(descriptionUrl).then { buildsInfo -> val data = JsonTreeParser.parse(buildsInfo) if (data !is JsonArray) { error("Response is expected to be an array.") } data.jsonArray.map { - val element = it as JsonElement - if (element.isNull) null else Build.create(element as JsonObject) + if (it.isNull) null else Build.create(it as JsonObject) } } @@ -405,12 +403,12 @@ fun main(args: Array) { else "" val requestedMetric = if (metric.startsWith("EXECUTION_TIME")) "EXECUTION_TIME" else metric - val url = "$metricUrl$requestedMetric$getParameters$branchParameter${ + val queryUrl = "$metricUrl$requestedMetric$getParameters$branchParameter${ if (parameters["type"] != "all") (if (getParameters.isEmpty() && branchParameter.isEmpty()) "?" else "&") + "type=${parameters["type"]}" else "" }&count=$buildsNumberToShow${getDatesComponents()}" - sendGetRequest(url) + sendGetRequest(queryUrl) }.toTypedArray() // Get metrics values for charts. @@ -422,8 +420,7 @@ fun main(args: Array) { } val labels = results.map { it.first } - val values = results[0]?.second?.size?.let { (0..it - 1).map { i -> results.map { it.second[i] } } } - ?: emptyList() + val values = results[0].second.size.let { (0..it - 1).map { i -> results.map { it.second[i] } } } labels to values } val labels = valuesList[0].first @@ -436,7 +433,7 @@ fun main(args: Array) { compileData = labels to values.map { it.map { it?.let { it / 1000 } } } compileChart = Chartist.Line("#compile_chart", getChartData(labels, compileData.second), - getChartOptions(valuesToShow["COMPILE_TIME"]!![0]!!["samples"]!!.split(',').toTypedArray(), + getChartOptions(valuesToShow["COMPILE_TIME"]!![0]["samples"]!!.split(',').toTypedArray(), "Time, milliseconds")) buildsInfoPromise.then { builds -> customizeChart(compileChart, "compile_chart", js("$(\"#compile_chart\")"), builds, parameters)