Rename params show/dumpProcessorTimings to show/dumpProcessorStats
^KT-51132 Fixed
This commit is contained in:
@@ -43,7 +43,7 @@ class KaptOptions(
|
||||
val processingClassLoader: ClassLoader?,
|
||||
//construct new classloader for these processors instead of using one defined in processingClassLoader
|
||||
val separateClassloaderForProcessors: Set<String>,
|
||||
val processorsPerfReportFile: File?
|
||||
val processorsStatsReportFile: File?
|
||||
) : KaptFlags {
|
||||
override fun get(flag: KaptFlag) = flags[flag]
|
||||
|
||||
@@ -73,7 +73,7 @@ class KaptOptions(
|
||||
|
||||
var mode: AptMode = AptMode.WITH_COMPILATION
|
||||
var detectMemoryLeaks: DetectMemoryLeaksMode = DetectMemoryLeaksMode.DEFAULT
|
||||
var processorsPerfReportFile: File? = null
|
||||
var processorsStatsReportFile: File? = null
|
||||
|
||||
fun build(): KaptOptions {
|
||||
val sourcesOutputDir = this.sourcesOutputDir ?: error("'sourcesOutputDir' must be set")
|
||||
@@ -88,7 +88,7 @@ class KaptOptions(
|
||||
mode, detectMemoryLeaks,
|
||||
processingClassLoader = null,
|
||||
separateClassloaderForProcessors = emptySet(),
|
||||
processorsPerfReportFile = processorsPerfReportFile
|
||||
processorsStatsReportFile = processorsStatsReportFile
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ interface KaptFlags {
|
||||
}
|
||||
|
||||
enum class KaptFlag(val description: String, val defaultValue: Boolean = false) {
|
||||
SHOW_PROCESSOR_TIMINGS("Show processor time"),
|
||||
SHOW_PROCESSOR_STATS("Show processor stats"),
|
||||
VERBOSE("Verbose mode"),
|
||||
INFO_AS_WARNINGS("Info as warnings"),
|
||||
USE_LIGHT_ANALYSIS("Use light analysis", defaultValue = true),
|
||||
|
||||
+13
-8
@@ -116,13 +116,13 @@ fun KaptContext.doAnnotationProcessing(
|
||||
logger.info("Annotation processing complete, errors: $errorCount, warnings: $warningCount")
|
||||
}
|
||||
|
||||
val showProcessorTimings = options[KaptFlag.SHOW_PROCESSOR_TIMINGS]
|
||||
if (logger.isVerbose || showProcessorTimings) {
|
||||
val loggerFun = if (showProcessorTimings) logger::warn else logger::info
|
||||
showProcessorTimings(wrappedProcessors, loggerFun)
|
||||
val showProcessorStats = options[KaptFlag.SHOW_PROCESSOR_STATS]
|
||||
if (logger.isVerbose || showProcessorStats) {
|
||||
val loggerFun = if (showProcessorStats) logger::warn else logger::info
|
||||
showProcessorStats(wrappedProcessors, loggerFun)
|
||||
}
|
||||
|
||||
options.processorsPerfReportFile?.let { dumpProcessorTiming(wrappedProcessors, options.processorsPerfReportFile, logger::info) }
|
||||
options.processorsStatsReportFile?.let { dumpProcessorStats(wrappedProcessors, it, logger::info) }
|
||||
|
||||
if (logger.isVerbose) {
|
||||
filer.displayState()
|
||||
@@ -137,14 +137,18 @@ fun KaptContext.doAnnotationProcessing(
|
||||
}
|
||||
}
|
||||
|
||||
private fun showProcessorTimings(wrappedProcessors: List<ProcessorWrapper>, logger: (String) -> Unit) {
|
||||
private fun showProcessorStats(wrappedProcessors: List<ProcessorWrapper>, logger: (String) -> Unit) {
|
||||
logger("Annotation processor stats:")
|
||||
wrappedProcessors.forEach { processor ->
|
||||
logger(processor.renderSpentTime())
|
||||
}
|
||||
logger("Generated files report:")
|
||||
wrappedProcessors.forEach { processor ->
|
||||
logger(processor.renderGenerations())
|
||||
}
|
||||
}
|
||||
|
||||
private fun dumpProcessorTiming(wrappedProcessors: List<ProcessorWrapper>, apReportFile: File, logger: (String) -> Unit) {
|
||||
private fun dumpProcessorStats(wrappedProcessors: List<ProcessorWrapper>, apReportFile: File, logger: (String) -> Unit) {
|
||||
logger("Dumping Kapt Annotation Processing performance report to ${apReportFile.absolutePath}")
|
||||
|
||||
apReportFile.writeText(buildString {
|
||||
@@ -260,8 +264,9 @@ private class ProcessorWrapper(private val delegate: IncrementalProcessor) : Pro
|
||||
numSourcesGenerated = sources?.size ?: -1
|
||||
} catch (e: Exception) {
|
||||
// Not much we can do
|
||||
} finally {
|
||||
sourcesGenerated.add(numSourcesGenerated)
|
||||
}
|
||||
sourcesGenerated.add(numSourcesGenerated)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user