Don't use aggregated GC metric for build reports
This commit is contained in:
committed by
Space Team
parent
a34657195b
commit
79fff92dc1
@@ -12,7 +12,10 @@ class GcMetrics : Serializable {
|
|||||||
|
|
||||||
private val myGcMetrics = HashMap<String, GcMetric>()
|
private val myGcMetrics = HashMap<String, GcMetric>()
|
||||||
fun addAll(gcMetrics: GcMetrics) {
|
fun addAll(gcMetrics: GcMetrics) {
|
||||||
myGcMetrics.putAll(gcMetrics.myGcMetrics)
|
gcMetrics.myGcMetrics.forEach { (key, value) ->
|
||||||
|
val gcMetric = myGcMetrics[key]
|
||||||
|
myGcMetrics[key] = gcMetric?.let { gcMetric + value } ?: value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun add(metric: String, value: GcMetric) {
|
fun add(metric: String, value: GcMetric) {
|
||||||
@@ -22,6 +25,8 @@ class GcMetrics : Serializable {
|
|||||||
fun asGcCountMap(): Map<String, Long> = myGcMetrics.mapValues { it.value.count }
|
fun asGcCountMap(): Map<String, Long> = myGcMetrics.mapValues { it.value.count }
|
||||||
fun asGcTimeMap(): Map<String, Long> = myGcMetrics.mapValues { it.value.time }
|
fun asGcTimeMap(): Map<String, Long> = myGcMetrics.mapValues { it.value.time }
|
||||||
fun asMap(): Map<String, GcMetric> = myGcMetrics
|
fun asMap(): Map<String, GcMetric> = myGcMetrics
|
||||||
|
|
||||||
|
fun isEmpty() = myGcMetrics.isEmpty()
|
||||||
}
|
}
|
||||||
data class GcMetric(
|
data class GcMetric(
|
||||||
val time: Long,
|
val time: Long,
|
||||||
@@ -30,4 +35,8 @@ data class GcMetric(
|
|||||||
operator fun minus(increment: GcMetric): GcMetric {
|
operator fun minus(increment: GcMetric): GcMetric {
|
||||||
return GcMetric(time - increment.time, count - increment.count)
|
return GcMetric(time - increment.time, count - increment.count)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
operator fun plus(increment: GcMetric?): GcMetric {
|
||||||
|
return GcMetric(time + (increment?.time ?: 0), count + (increment?.count ?: 0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-7
@@ -52,7 +52,7 @@ internal class PlainTextBuildReportWriter(
|
|||||||
// TODO: If it is confusing, consider renaming "tasks" to "build operations" in this class.
|
// TODO: If it is confusing, consider renaming "tasks" to "build operations" in this class.
|
||||||
printBuildInfo(build)
|
printBuildInfo(build)
|
||||||
if (printMetrics) {
|
if (printMetrics) {
|
||||||
printMetrics(build.aggregatedMetrics, newLineBetweenSections = true)
|
printMetrics(build.aggregatedMetrics, aggregatedMetric = true)
|
||||||
p.println()
|
p.println()
|
||||||
}
|
}
|
||||||
printTaskOverview(build)
|
printTaskOverview(build)
|
||||||
@@ -77,17 +77,19 @@ internal class PlainTextBuildReportWriter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun printMetrics(buildMetrics: BuildMetrics, newLineBetweenSections: Boolean = false) {
|
private fun printMetrics(buildMetrics: BuildMetrics, aggregatedMetric: Boolean = false) {
|
||||||
printBuildTimes(buildMetrics.buildTimes)
|
printBuildTimes(buildMetrics.buildTimes)
|
||||||
if (newLineBetweenSections) p.println()
|
if (aggregatedMetric) p.println()
|
||||||
|
|
||||||
printBuildPerformanceMetrics(buildMetrics.buildPerformanceMetrics)
|
printBuildPerformanceMetrics(buildMetrics.buildPerformanceMetrics)
|
||||||
if (newLineBetweenSections) p.println()
|
if (aggregatedMetric) p.println()
|
||||||
|
|
||||||
printBuildAttributes(buildMetrics.buildAttributes)
|
printBuildAttributes(buildMetrics.buildAttributes)
|
||||||
if (newLineBetweenSections) p.println()
|
|
||||||
|
|
||||||
printGcMetrics(buildMetrics.gcMetrics)
|
//TODO: KT-57310 Implement build GC metric in
|
||||||
|
if (!aggregatedMetric) {
|
||||||
|
printGcMetrics(buildMetrics.gcMetrics)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun printBuildTimes(buildTimes: BuildTimes) {
|
private fun printBuildTimes(buildTimes: BuildTimes) {
|
||||||
@@ -173,7 +175,7 @@ internal class PlainTextBuildReportWriter(
|
|||||||
p.println("${gcMetric.key}:")
|
p.println("${gcMetric.key}:")
|
||||||
p.withIndent {
|
p.withIndent {
|
||||||
p.println("GC count: ${gcMetric.value.count}")
|
p.println("GC count: ${gcMetric.value.count}")
|
||||||
p.println("GC time: ${gcMetric.value.time}")
|
p.println("GC time: ${formatTime(gcMetric.value.time)}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user