Add compiler metrics to JPS build report
#KT-63549: Fixed
This commit is contained in:
committed by
Space Team
parent
6cff71e7d1
commit
6bbf5b83c8
+1
@@ -26,6 +26,7 @@ enum class JpsBuildPerformanceMetric(
|
||||
DAEMON_GC_COUNT(readableString = "Count of GC", type = ValueType.NUMBER),
|
||||
|
||||
COMPILE_ITERATION(parent = null, "Total compiler iteration", type = ValueType.NUMBER),
|
||||
IC_COMPILE_ITERATION(parent = COMPILE_ITERATION, "Total kotlin compiler iteration", type = ValueType.NUMBER),
|
||||
ANALYZED_LINES_NUMBER(parent = COMPILE_ITERATION, "Number of lines analyzed", type = ValueType.NUMBER),
|
||||
CODE_GENERATED_LINES_NUMBER(parent = COMPILE_ITERATION, "Number of lines for code generation", type = ValueType.NUMBER),
|
||||
ANALYSIS_LPS(parent = COMPILE_ITERATION, "Analysis lines per second", type = ValueType.NUMBER),
|
||||
|
||||
+7
-1
@@ -20,9 +20,15 @@ interface BuildTime : Serializable {
|
||||
}
|
||||
|
||||
|
||||
@Suppress("Reformat")
|
||||
enum class JpsBuildTime(private val parent: JpsBuildTime? = null, private val readableString: String) : BuildTime {
|
||||
|
||||
JPS_ITERATION(readableString = "Jps iteration")
|
||||
JPS_ITERATION(readableString = "Jps iteration"),
|
||||
COMPILATION_ROUND(JPS_ITERATION, "Sources compilation round"),
|
||||
COMPILER_PERFORMANCE(COMPILATION_ROUND, readableString = "Compiler time"),
|
||||
COMPILER_INITIALIZATION(COMPILER_PERFORMANCE, "Compiler initialization time"),
|
||||
CODE_ANALYSIS(COMPILER_PERFORMANCE, "Compiler code analysis"),
|
||||
CODE_GENERATION(COMPILER_PERFORMANCE, "Compiler code generation"),
|
||||
;
|
||||
|
||||
override fun getReadableString(): String = readableString
|
||||
|
||||
+15
-23
@@ -15,34 +15,21 @@ import java.io.Serializable
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class FileReportService<B : BuildTime, P : BuildPerformanceMetric>(
|
||||
private val outputFile: File,
|
||||
open class FileReportService<B : BuildTime, P : BuildPerformanceMetric>(
|
||||
buildReportDir: File,
|
||||
projectName: String,
|
||||
private val printMetrics: Boolean,
|
||||
private val logger: KotlinLogger,
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private val formatter = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").also { it.timeZone = TimeZone.getTimeZone("UTC") }
|
||||
fun <B : BuildTime, P : BuildPerformanceMetric> reportBuildStatInFile(
|
||||
buildReportDir: File,
|
||||
projectName: String,
|
||||
includeMetricsInReport: Boolean,
|
||||
buildData: List<CompileStatisticsData<B, P>>,
|
||||
startParameters: BuildStartParameters,
|
||||
failureMessages: List<String>,
|
||||
logger: KotlinLogger,
|
||||
) {
|
||||
val ts = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Calendar.getInstance().time)
|
||||
val reportFile = buildReportDir.resolve("$projectName-build-$ts.txt")
|
||||
|
||||
FileReportService<B, P>(
|
||||
outputFile = reportFile,
|
||||
printMetrics = includeMetricsInReport,
|
||||
logger = logger
|
||||
).process(buildData, startParameters, failureMessages)
|
||||
}
|
||||
}
|
||||
private val ts = SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(Calendar.getInstance().time)
|
||||
private val outputFile = buildReportDir.resolve("$projectName-build-$ts.txt")
|
||||
|
||||
private lateinit var p: Printer
|
||||
protected lateinit var p: Printer
|
||||
|
||||
open fun printCustomTaskMetrics(statisticsData: CompileStatisticsData<B, P>) {}
|
||||
|
||||
fun process(
|
||||
statisticsData: List<CompileStatisticsData<B, P>>,
|
||||
@@ -263,14 +250,18 @@ class FileReportService<B : BuildTime, P : BuildPerformanceMetric>(
|
||||
p.println()
|
||||
}
|
||||
|
||||
private fun printTasksLog(statisticsData: List<CompileStatisticsData<B, P>>) {
|
||||
private fun printTasksLog(
|
||||
statisticsData: List<CompileStatisticsData<B, P>>,
|
||||
) {
|
||||
for (task in statisticsData.sortedWith(compareBy({ -it.getDurationMs() }, { it.getStartTimeMs() }))) {
|
||||
printTaskLog(task)
|
||||
p.println()
|
||||
}
|
||||
}
|
||||
|
||||
private fun <B : BuildTime, P : BuildPerformanceMetric> printTaskLog(statisticsData: CompileStatisticsData<B, P>) {
|
||||
private fun printTaskLog(
|
||||
statisticsData: CompileStatisticsData<B, P>,
|
||||
) {
|
||||
val skipMessage = statisticsData.getSkipMessage()
|
||||
if (skipMessage != null) {
|
||||
p.println("Task '${statisticsData.getTaskName()}' was skipped: $skipMessage")
|
||||
@@ -295,6 +286,7 @@ class FileReportService<B : BuildTime, P : BuildPerformanceMetric>(
|
||||
statisticsData.getBuildTimesMetrics(), statisticsData.getPerformanceMetrics(), statisticsData.getNonIncrementalAttributes(),
|
||||
statisticsData.getGcTimeMetrics(), statisticsData.getGcCountMetrics()
|
||||
)
|
||||
printCustomTaskMetrics(statisticsData)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ import java.io.IOException
|
||||
|
||||
private val LINE_SEPARATOR = System.getProperty("line.separator")
|
||||
|
||||
internal class Printer(
|
||||
class Printer(
|
||||
private val out: Appendable,
|
||||
private val indentUnit: String = " ",
|
||||
private var indent: String = ""
|
||||
|
||||
Reference in New Issue
Block a user